我在Chrome和Safari中遇到jquery問題,該腳本在Mozilla和Opera中運行正常。Chrome和Safari中的jQuery問題:在Mozilla和Opera中運行正常:請幫忙
請檢查該鏈接http://phpmagic.info/jquery/
當你點擊按鈕,所有的箱子應該在textare川方往下走,則該值在第一個框,同樣應該發生,因爲很多時候你點擊按鈕,這在Mozilla和Opera中工作正常,但不是Chrome和safari(也在IE6中),在這些瀏覽器中沒有新盒子下來,只存在
請給我解決方案(請檢查源代碼):
<script language="javascript" src="jquery-1.4.2.min.js"></script>
<script language="javascript">
$(document).ready(function() {
var top = 0;
$('#contents div').each(function(index, val) {
$(this).css('top', top + 'px');
top = top + 61;
});
$('#btn').bind('click', function() {
$('#contents div').each(function(index, val) {
var newtop = parseInt($(this).css('top')) + 61;
//$(this).css('top',newtop +'px');;
$(this).animate({
top: newtop + 'px'
}, 800, function() {
//
});
});
$('#contents div:first').before('<div class="link">' + document.getElementById('val').value + '</div>');
});
})
</script>
它創建新的'div'很好,但他們沒有正確地移動。 ...爲什麼在使用jQuery時使用'document.getElementById()'? – 2010-10-12 18:22:49