我有这段 HTML 代码
<div id="countdown">
<ul>
<li id="giorni"><span class="num red">66</span><span class="lab">Giorni</span></li>
<li id="ore"><span class="num red">23</span><span class="lab">Ore</span></li>
<li id="minuti"><span class="num red">44</span><span class="lab">Minuti</span></li>
<li id="secondi"><span class="num red">14</span><span class="lab">Secondi</span></li>
</ul>
</div>
我想替换每个具有 num 类的 span 的内容。为了做到这一点,我写了:
var countdown = {
init: function( config ) {
this.dataX = Date.parse(new Date(2012, 5, 30));
this.adesso = new Date().getTime();
this.giorni = config.container.find('li#giorni');
console.log(this.giorni);
this.count();
},
... some other code ...
};
countdown.init({
container: $('div#countdown ul');
});
我真的不明白为什么如果我尝试登录this.giorni
我会得到[]
响应,但是如果我将相同的代码写入控制台,它会返回我需要的节点。