Click here to Skip to main content
15,896,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
can you help me on this markup on how to hide 2nd li tag using javascript?
the li tags is dynamic populated item like the example below

XML
<ul id="mUl">
    <li>a</li>
    <li>b</li>
    <li>c</li>
    <li>d</li>
    <li>e</li>
    <li>f</li>
</ul>



thanks in advance
Posted

use jquery.

$("ui li")[1].css("display","none");

otherwise,

document.getElementById("mUl").children[1].style.display="none";
 
Share this answer
 
v2
Comments
zyck 17-Feb-12 1:18am    
how about javascript? w/o using jquery
zyck 17-Feb-12 1:29am    
thank you!
<html>
<head>
<script>
function invisible()
{
document.getElementById("mUl").children[2].style.display="none";
}
</script>
</head>
<body onload="invisible()">
<ul id="mUl">
<li>a</li>
<li>b</li>
<li>c</li>
<li>d</li>
<li>e</li>
<li>f</li>
</ul>
</body>
</html>

//save the above code as ".html" and run at browser. you ll find ur 2nd li tag hidden.
 
Share this answer
 
Comments
zyck 17-Feb-12 1:56am    
thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900