我的HTML列表中有一些引號。我還有一個叫做「演講」的div,它的風格看起來像一個講話泡泡。點擊講話泡泡按順序顯示列表項目 - 不能在IE8中工作
程序運行時,第一個報價顯示在氣泡中,當它被點擊時,它跳過引號列表。
我的問題是,在IE8中沒有任何顯示在泡沫中,我不能解決原因。有人能告訴我我做錯了什麼,或者告訴我如何做得更好。
這裏是列表...
<ul class="facts">
<li>
<span>What goes ho-ho whoosh, ho-ho whoosh?<br/>Santa caught in a revolving door.</span>
</li>
<li>
<span>Whats white and goes up? <br/> A confused snowflake.</span>
</li>
<li>
<span>Which Christmas carols do parents like best? <br/> Silent Night.</span>
</li>
<li>
<span>How did the snowman get to school?<br/>On his icicle.</span>
</li>
<li>
<span>What do you call a three-legged donkey?<br/> A wonkey.</span>
</li>
</ul>
,這裏是腳本...
jQuery.fn.extend({
rnditem : function(l) {
var a = [],
current = jQuery(this).html().trim(),
index,
next;
Array.prototype.forEach.call(l, function(item) {
a.push(jQuery(item).html()
jQuery.trim();
});
index = a.indexOf(current) + 1;
if (index < 0 || index >= l.length) {
index = 0;
}
next = (l.eq(index).html());
jQuery(this).html(next);
return this;
}
});
jQuery(document).ready(function() {
var list = jQuery(".facts").find("li");
jQuery(document.body).on('click','.speech', function() {
jQuery(this).rnditem(list);
});
jQuery(".speech").trigger("click");
});
小提琴:http://jsfiddle.net/S79qp/425/
爲什麼小提琴和代碼在這裏不同? – epascarello 2013-04-23 16:01:18