简体   繁体   中英

Hide all li tags with jquery

Please help me to complete my code. I want to hide all <li> tags on body onload.

$(document).ready(function () {
$('li > ul').hide();    
});

Please give me the right variant for the code!

ul > li ,不是li > ul

$(document).ready(function () { $('ul > li').hide(); });
$(function(){
  $('li').hide()
})

This will search and hide every <li> tag on the page. It is better to narrow down the search to improve performance Ex: $('#mydiv li') where mydiv is the id of the ul tag <ul id="mydiv"> .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM