I'm trying to get the class of the selected option and use that in a compare statement to find which class it is.
(我试图获取所选选项的类,并在compare语句中使用它来查找它是哪个类。)
I get an undefined value.
(我得到一个未定义的值。)
The option tag has a class set to it. (option标记设置了一个类。)
Why am I not getting a value back?
(为什么我没有找回价值?)
Html:
(HTML:)
<select name="datagrid_filter" onchange="startFilter();">
<option>All</option>
<option disabled="true">Assignment:</option>
<option disabled="true">Client:</option>
<option disabled="true">Type:</option>
<option class="type" value="Activity">   Activity</option>
<option class="type" value="Alert">   Alert</option>
<option class="type" value="Lead">   Lead</option>
<option class="type" value="Notification">   Notification</option>
</select>
Javascript:
(Javascript:)
var cs1 = $("option:selected", this).attr("class");
if(cs1 == 'Type'){
//do something
}
ask by user2671355 translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…