tags:

views:

447

answers:

3
$('#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

+5  A: 

$(item).attr('disabled', 'true'); should work

See: http://docs.jquery.com/Core/jQuery#elements

jimyi
A: 

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.

Peter
A: 
$(item).attr("whatever")

Jquery takes many different types of arguments, including straight up HTML elements, read the doco

larson4