Reputation: 175
I was trying to hide HTML list using the Jquery. Please tell me the suggestion where i am doing wrong.
This is the rendered code:
<div id="TabStrip_3" class="t-widget t-tabstrip t-header">
<ul class="t-reset t-tabstrip-items">
<li class="t-item t-state-default t-state-active">
<a class="t-link" href="#TabStrip_3-1">Details</a>
</li>
<li id="3" class="t-item t-state-default">
<a class="t-link" href="/Acquisition/PoDetails/Create/3">Create New Detail</a>
</li>
</ul>
</div>
I need to hide the li using its Id. Please help for this.
Thanks,
Upvotes: 0
Views: 1230
Reputation: 47794
As you need to only hide list with id '3', you may use jquery .hide().
$('#3').hide();
Fiddle Link : http://jsfiddle.net/j5wAp/
Upvotes: 0
Reputation: 23208
Using jQuery filter. jsfiddle
var tlen = $("#TabStrip_3 ul.t-reset li").length;
$("#TabStrip_3 ul.t-reset li").filter(function(index){
return tlen-index < 4;
}).hide();
Upvotes: 0
Reputation: 1137
According to HTML spec you can't start id
attribute with number.
To hide all li
under particular element use:
$('#TabStrip_3').find('li').hide()
In your case you should change your id
and then you could hide it simply:
$('#my-li-id').hide()
Upvotes: 1
Reputation: 34905
Try this code:
$(document).ready(function () {
$('#3').hide();
});
Upvotes: 0