问题
my project is asp.net MVC, using Telerik MVC combobox. I can change the sytle of the first item if I use:
var item = combobox.dropDown.$items.first();
item.addClass('test');
Or change all items, using:
combobox.dropDown.$items.addClass('test');
But I need to change just specific items (based on a model), I tried:
combobox.dropDown.$items[1].addClass('test');
I get this error:
Object doesn't support property or method 'addClass
'
回答1:
If it's a jQuery object, you should replace:
combobox.dropDown.$items[1].addClass('test');
With:
combobox.dropDown.$items.eq(1).addClass('test');
$items[1]
gives you the DOM object which doesn't have the jQuery addClass
function.
$items.eq(1)
gives you the jQuery object which has the jQuery addClass
function.
来源:https://stackoverflow.com/questions/12556524/combobox-item-style