我有所有具有相同類的div列表,我想對所有這些不是點擊的應用函數(this
),我如何選擇!this
與jQuery?如何選擇不是'this'的元素?
更新: 我做了這個,它不工作,任何想法爲什麼?
$("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();
});
});
});
它不工作,因爲你說:'李(每個),而不是李 - > hide' –
是'this'這裏包括了所有的' li'元素?不只是點擊一個?那麼我怎麼才能得到點擊'li'? – ilyo
什麼是'newStatus'? – thecodeparadox