-4

我试图click在我的项目中向 div Id 添加一个事件,但它抛出了一个错误。我不知道为什么。有人可以看看代码吗?

HTML:

<div id="container">
    <div id="header1">
        <input type="button" value="Search and Highlight!!" style="position: absolute; right: 100px; top: 10px;" />
    </div>
...

jQuery:

  var searchAttachPoint = document.querySelector('.header1');
  $('#header1').live("click", function () {
      myNameSpace.searchPrompt("Key the text and press Ok", false)
  }); // The error is thrown in this line
  var attachpoint = document.querySelector('.buttonAttachPoint');
  $(document).on('load', myNameSpace.LoadAllBooks("ajax/metadata.json", this.attachpoint));
4

1 回答 1

1

.live()已折旧,可以替换为.on()

所以,

改变:$('#header1').live('click',function(){...})

至:$('body').on('click','#header1',function(){...})

body应替换为最近的静态父级#header1

于 2013-03-28T14:12:37.453 回答