这是我的代码:
<script type='text/javascript'>
$(document).ready(function() {
$('#test').load('http://foobar.com/view.php?id=1186', function() {
console.log($('.weekdates'));
var weeks = $('.weekdates');
weeks.each(function(i, val) {
alert($(this).text());
});
});
});
</script>
调用的结果console.log
是:
[prevObject: b.fn.b.init[1], context: document, selector: ".weekdates", jquery: "1.9.1", constructor: function…]
context: document
length: 0
prevObject: b.fn.b.init[1]
selector: ".weekdates"
__proto__: Object[0]
任何想法为什么在结果集中找不到元素?它与动态加载 HTML 有关吗?
这是添加的 HTML:
<h3 class="weekdates"> 23 de enero - 29 de enero</h3>