开发者

How Do I convert the selected items in a form to Objects in JQuery

开发者 https://www.devze.com 2022-12-09 13:34 出处:网络
Can I convert the selec开发者_运维百科ted items in a form to Custom Objects in JQuery?.If you wrap any HTML element expression in $() it becomes jQuery friendly, and you can call the jQuery API method

Can I convert the selec开发者_运维百科ted items in a form to Custom Objects in JQuery?.


If you wrap any HTML element expression in $() it becomes jQuery friendly, and you can call the jQuery API methods and properties on it. For example,

var el = document.getElementById('inputText');

referring to an HTML element in the DOM can be turned into

$(el)

to become a jQuery object. You can use jQuery members on it like Manipulation methods and Attribute members, like setting the value:

$(el).val('hi'); // assign a value to the input field

View the jQuery Selectors documentation to know the various ways to specify elements in the DOM to turn into jQueryable objects. For example var allInputs = $(":input"); to get a set of all input fields on your form so you can manipulate them all at once.

I'm trying to guess the direction of your question and hope this helps. My mind-reading skills are sometimes better than at other times!

0

精彩评论

暂无评论...
验证码 换一张
取 消