我有以下HTML摘录:jQuery选择用于动态地生成的元素
console.log($('#contentX h1'));
输出是
[<h1>MyHeading1</h1>]
:
<div id="contentX"><h1>MyHeading1</h1></div>
我可以用jQuery选择具有以下syccessfully代码段
但是,它确实不是工作时我动态从容装载内容。例如,
HTML代码片段:
<div id="content"></div>
jQuery代码片段:
$('#content').load('foo.html')); // the content is loaded correctly with <h1> tag
jQuery代码片断并不工作:
console.log($('#content h1')); // it returns []. I was expecting to return something.
我想知道,如果这是类似于事件绑定的行为:.click()vs .live ()。
在此先感谢您的帮助。
的,什么是'foo.html'包含哪些内容? – Dogbert