當我想在嵌套語句中引用「this」時會發生什麼?
下面是一個例子來說明我通過上面的意思是:
$("input").blur(function(){
var theThis = $(this);
if(!($(".invalid").length > 0)){
//if there's no messages already open
theThis.data("validator").checkValidity();
}else{
//add the message to the next to be displayed
nextToAlert.push(theThis);
//bind an event to the errored field being changed
$(".invalid").on("change", function(){
var me = $(this);
if(!me.hasClass('invalid')){
nextToAlert.pop().checkValidity();
}
});
}
});
元素被選中,這就是發生了什麼 – 2012-08-15 08:54:15
是的,不是一個很好的問題。 – Archer 2012-08-15 08:55:10
所以第二個這是本地的,第一個這是超出範圍? – 2012-08-15 08:56:03