我有一个搜索框,其中包含两个选项卡以选择要搜索的类型。我想添加.active类来列出其search_type等于来自请求的参数(即,params [request_type])的项目。使用jQuery从HTML元素获取标记
<ul data-tabs="tabs" class="tabs">
<li search_type="Things">
<a href="#Things">Things</a>
</li>
<li search_type="People">
<a href="#People">People</a>
</li>
</ul>
我试图jQuery来比较:
$('.tabs .li).(function(){
if($(this).search_type == myParams){
$(this).addClass('.active');
}
});
但是,我的$(本).search_type真可谓是不确定的,即使在网络浏览器中,元素正确显示为:
<li search_type="Things">
<a href="#Things">Things</a>
</li>
我的问题是:如何从li获取search_type?
谢谢。