Home >Web Front-end >JS Tutorial >When loading the list, jquery gets the attributes of the first li in ul_jquery
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();