我有所有具有相同类的 div 列表,我想将一个函数应用于所有不是单击的 ( this
) 的函数,我如何!this
使用 jQuery 进行选择?
更新:我做了这个,但它不起作用,有什么想法吗?
$("li").each(function(){
$("li").not(this).click(function(e) {
$(this).hide();
});
});
更新2:这是整个实际代码:
$(".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();
});
});
});