我无法专注于更新当前值。这段代码中是否存在错误,或者我是否缺少更简洁的方法?我可以通过“this”或“event”吗?
我收到此错误:
'focused is not defined'
我有这段代码:
$("input, select, textarea, button, .link, div, .button").live({
click:clearDefault,
focusin:function() {focused = ($(this).attr('title'))},
focusout:function() {focused = false},
mouseover:onHelp,
mouseout:helpFallback
});
映射到这些功能:
function onHelp() {
if (!helpDiv) {
helpDiv = $('#helpText');
}
var $this = $(this);
var text = $this.attr('title');
if ($this.attr('titlehtml')) {
var text = $this.attr('titlehtml');
}
if ($this.hasClass('screenshot')) {
text += "<img src='images/icon_table_" + $this.attr('id') + ".png' >";
}
if ($this.attr('errorhtml')) {
text += "<div id='userError'>"+$this.attr('errorhtml')+"</div>";
}
helpDiv.show().html(text);
}
function helpFallback() {
if (focused) {
helpDiv.show().html(focused);
} else {
helpDiv.hide();
}
}