Home > Web Front-end > JS Tutorial > body text

When loading the list, jquery gets the attributes of the first li in ul_jquery

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

When loading the list, you want to select the first item by default. top_menu is the ID of ul

You can get the first li tag under ul through $("#top_menu li:first"). Then you can use

For example, modify attributes: $("#top_menu li:first").attr("class","select");

Trigger event: $("#top_menu li:first").click();

If you want to get the a tag under li, as follows:

$("#top_menu li:first a")

You can also modify the attributes: $("#top_menu li:first a").attr("","");

Trigger event: $("#top_menu li:first a").click();

Copy code The code is as follows:


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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template