admin管理员组

文章数量:1323342

Please help me to plete 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!

Please help me to plete 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!

Share Improve this question edited Mar 19, 2011 at 23:29 Hussein 42.8k25 gold badges115 silver badges143 bronze badges asked Mar 19, 2011 at 6:52 Avaz Avaz 291 silver badge6 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

It's ul > li, not 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">.

本文标签: javascriptHide all li tags with jqueryStack Overflow