S L
S L

Reputation: 14318

Filter other than this

How to filter the current item from the list of items. Eg.

$('.div').click(
    function (){
        $(this).val('this is clicked');

        //! get the items that are not clicked

    }
)

$('.div') returns a list of items, and one of them is clicked. How to get the list of item, that are not clicked.

Note: I am not looking the solution that adds attribute to the clicked item (or unlicked item) and filters it.

Upvotes: 8

Views: 3374

Answers (3)

Elad Lachmi
Elad Lachmi

Reputation: 10561

How about $('.div:not(this)')?

Upvotes: 0

stef
stef

Reputation: 14268

$('.div').click(
    function (){

        $(this).val('this is clicked');

        var others = $(".div").not($(this));

    }
)

Upvotes: 9

Andomar
Andomar

Reputation: 238176

Try the siblings selector:

$(this).siblings()

Upvotes: 2

Related Questions