$('#tags option').each(function(index, item) {
// var i = this;
//if (jQuery.inArray(i.value, idArray)) {
// i.attr('disabled', 'true');
// }
item.attr('disabled', 'true');
});
How to I convert the item parameter into Jquery object so I can use all the nicety's like .attr?
Thanks
var $this = $(myObject); $this is a jQuery object. You can create jQuery objects from DOM elements.
Answer: Use the jQuery $. map() Method You can simply use the $. map() method to convert a JavaScript object to an array of items.
You can just wrap it like this:
var jQueryItem = $(item);
where item
is a DOM element. In fact, you'll find yourself doing this a lot in callback functions, since usually this
refers to a DOM element and you'll usually want to operate on that using jQuery API calls.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With