Combobox项目风格

时间:2012-09-23 21:44:01

标签: jquery asp.net-mvc combobox telerik telerik-mvc

我的项目是asp.net MVC,使用Telerik MVC组合框。如果我使用的话,我可以改变第一项的风格:

var item = combobox.dropDown.$items.first();
item.addClass('test');

或使用以下方式更改所有项目:

combobox.dropDown.$items.addClass('test');

但我需要更改特定项目(基于模型),我试过:

combobox.dropDown.$items[1].addClass('test');

我收到此错误:  Object doesn't support property or method 'addClass

1 个答案:

答案 0 :(得分:2)

如果是jQuery对象,则应替换:

combobox.dropDown.$items[1].addClass('test');

使用:

combobox.dropDown.$items.eq(1).addClass('test');

$items[1]为您提供了没有jQuery addClass函数的DOM对象。 $items.eq(1)为您提供了具有jQuery addClass函数的jQuery对象。

相关问题