0

我无法专注于更新当前值。这段代码中是否存在错误,或者我是否缺少更简洁的方法?我可以通过“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();
    }
}
4

1 回答 1

0

定义如下焦点并设置一些默认值

var focused = false;
于 2011-06-29T18:18:08.573 回答