How to select element which is not 'this'?

javascript, jquery

Solution

Use the `.not()` function:

$('.yourclass').click(function() {
    $('.yourclass').not(this).yourFunc();
});

Problem

I have list of divs all with the same class, I want to apply a function to all of them which are not the clicked one (`this`), how can i select `!this` with jQuery? UPDATE: I've made this and it is not working, any ideas why? ``` $("li").each(function(){ $("li").not(this).click(function(e) { $(this).hide(); }); }); ``` UPDATE 2: this is the whole actual code: ``` $(".mark").click(function(e) { e.preventDefault(); var id = "#" + $(this).parent().parent().parent().parent().attr("id") + " "; var currentStatus = "deleted"; // to be replaced with actual status var currentStatusClass = "." + currentStatus + "-heading"; $(id + currentStatusClass).show(); $(id + ".edit-headings").click(function(){ $(this).find(".headings-status").show().addClass("bg-hover"); $(id + ".headings-status").click(function() { $(id + ".headings-status").not(this).hide(); }); }); }); ```

Original source