Javascript 在divs上添加循环函数
JS:Javascript 在divs上添加循环函数,javascript,jquery,Javascript,Jquery,JS: 函数houseScroll(){ var house=[‘一’、‘二’、‘三’、‘四’、‘五’、‘六’、‘七’、‘八’、‘九’]; randClass=house[Math.floor(Math.random()*house.length)]; $(“#房屋”).stop().animate({ '左':-$(此).outerWidth(真) },100000,‘线性’; if(“#房屋分区:第一个孩子”)。户外宽(真){ $('houses div:last')。在('')之后; }
函数houseScroll(){
var house=[‘一’、‘二’、‘三’、‘四’、‘五’、‘六’、‘七’、‘八’、‘九’];
randClass=house[Math.floor(Math.random()*house.length)];
$(“#房屋”).stop().animate({
'左':-$(此).outerWidth(真)
},100000,‘线性’;
if(“#房屋分区:第一个孩子”)。户外宽(真){
$('houses div:last')。在('')之后;
}
}
我想在浏览器退出我的第一个项目时,在最后一个项目中添加一个新项目。已尝试(如果
),但不起作用
我如何修复它?在if条件下,您错过了$,我想应该是if($('house div:first child')。outerWidth(true)){insteadHTML?您能创建一个小提琴吗?
function houseScroll() {
var house = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'];
randClass = house[Math.floor(Math.random() * house.length)];
$('#houses').stop().animate({
'left': -$(this).outerWidth(true)
}, 100000, 'linear');
if (('#house div:first-child').outerWidth(true)) {
$('#houses div:last').after('<div class="item current-last ' + randClass + '"></div>');
}
}