jquery selector does not work on element inside script tag using Cassette
问题 When trying to access data-onload using $("#index").data("onload") I get back 'undefined' : <script type="text/html"> <section id="index" data-onload="app.load()"> <div data-bind="text:name"></div> </section> </script> Without the surrounding script tag everything works fine. This is loaded using Cassette which wraps it inside script tags. What am I doing wrong? 回答1: The contents of the script tag are not part of the DOM tree for your document. If you think about it, this makes sense, since