伙计们:)
$('#loginbox').blur(function(){
var focusedInputs = null;
$('#loginbox table tbody tr td input').focus(function(){
focusedInputs = this;
});
alert(focusedInputs);
if (focusedInputs == null) {
$('#loginbox').stop().fadeOut('fast',function(){
$('#loginlink').prop('href','#login');
window.location.hash = '#';
});
$('#loginlink').removeClass('selected');
$('.tooltip').css('display','none');
Cufon.refresh();
}
});
它警告我'nul',但如果我在焦点功能中写警告(focusedInputs):
$('#loginbox table tbody tr td input').focus(function(){
focusedInputs = this;
alert(focusedInputs);
});
警告元素......我不知道问题出在哪里......谢谢!
答案 0 :(得分:0)
试试这个,你真的不应该在一个模糊事件中绑定一个焦点事件,除非你打算解开它。
var focusedInputs = null;
$('#loginbox table tbody tr td input').focus(function(){
focusedInputs = this;
}); // do you also need a blur event here to clear focusedInputs?
$('#loginbox').blur(function(){
alert(focusedInputs);
if (focusedInputs == null) {
$('#loginbox').stop().fadeOut('fast',function(){
$('#loginlink').prop('href','#login');
window.location.hash = '#';
});
$('#loginlink').removeClass('selected');
$('.tooltip').css('display','none');
Cufon.refresh();
}
});