john
john

Reputation: 801

hide div tag where id with jquery and mvc

How to hide div where id with jquery and mvc?

<div class="List-Display">
    @for(int i=1;i<=10;i++)
    {
        <div  id="@i">
            <span>content</span>
        </div>
        <button onclick="display(@i)" type="button">
    }
 </div>

I've tried the following but not worked!

<script>
    function display(parameters) {
        $('.List-Display').find('div[id!=' + parameters + ']').hide();
        //or
            $('.List-Display').filter('div[id!=' + parameters + ']').hide();
        }
    </script>

I need to hide div tag where id!=parameters. But I have no idea!!

Upvotes: 0

Views: 287

Answers (2)

john
john

Reputation: 801

i use :

$('.List-Display').children('div:not("#' + parameters + '")').hide();

. its worked;

Upvotes: 0

palaѕн
palaѕн

Reputation: 73906

You can do this:

$('.List-Display').find('div:not("#'+ parameters + '")').hide();

Upvotes: 1

Related Questions