Dheyvendaran
Dheyvendaran

Reputation: 175

Hide list under ul using Jquery

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

Answers (5)

Yasser Shaikh
Yasser Shaikh

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

Anoop
Anoop

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

Anton Rudeshko
Anton Rudeshko

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

Anton
Anton

Reputation: 32581

$('#TabStrip_3 li').hide()​

This hides all the lis in the div.

Upvotes: 0

Konstantin Dinev
Konstantin Dinev

Reputation: 34905

Try this code:

$(document).ready(function () {
    $('#3').hide();
});

Upvotes: 0

Related Questions