Search code examples
jqueryjquery-selectorsjquery-filter

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.


Solution

  • $('.div').click(
        function (){
    
            $(this).val('this is clicked');
    
            var others = $(".div").not($(this));
    
        }
    )