Jquery gets the property of the first li in ul when the list is loaded
- 2020-03-30 04:15:27
- OfStack
Get the first li tag of ul by $("#top_menu li:first"). And then you can use it
Change the properties such as: $(" # top_menu li: first "). Attr (" class ", "select");
Trigger event: $("#top_menu li:first").click();
If you want to get the a tag under li, it is as follows:
$(" # top_menu li: first a ")
$("#top_menu li:first a").attr("","");
Trigger event: $("#top_menu li:first a").click();
<ul class="nav white" id="top_menu" name="top_menu">
<!-- Level 1 menu -->
<s:iterator value="list" status="st">
<li><a onclick=""><s:property value="menuName" /></a></li>
</s:iterator>
</ul>