http://jsfiddle.net/suenot/3b3XM/1/jQuery的偏移()在Firefox 12
// in FF and IE each() don't work offset()
// $(this).offset().top return empty string
$(document).ready(function(){
var index = 0;
$('.box').each(function(){
var background = $(this).css('background');
$(this).css('background', 'none');
var height = $(this).css('height');
var top = $(this).offset().top;
$('body').prepend('<div id="box' + ++index + '"></div>');
$('#box' + index).css({
'height': height,
'background': background,
'position': 'absolute',
'z-index': '-1',
'top': top,
'width': '100%'
});
});
});
請幫助我,我無法找到解決方案返回每個空字符串()。
剛剛在FF 12中測試過,它工作正常,'.offset()。top'返回一個值。 –
在每個()測試?在jsfiddle也工作?對不起我的英語不好。 – suenot
請發佈一些代碼片段,而不僅僅是一個鏈接。 – jbabey