-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 に答える