当我想在嵌套语句中引用“this”时会发生什么,它使用哪个“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();
}
});
}
});