加载列表时jquery获取ul中第一个li的属性_jquery

WBOY
Release: 2016-05-16 16:32:23
Original
1745 people have browsed it

当加载列表时,默认希望选中第一条。top_menu 为ul的ID

通过 $("#top_menu li:first") 就可以获取到 ul下第一个li标签。然后就可以利用

例如 修改属性:$("#top_menu li:first").attr("class","select");

触发事件:$("#top_menu li:first").click();

如果想获取li下的 a标签,如下:

$("#top_menu li:first a")

也可以 修改属性:$("#top_menu li:first a").attr("","");

触发事件:$("#top_menu li:first a").click();

复制代码代码如下:
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!