Uncaught TypeError: Cannot use 'in' operator to search for 'marginTop' in undefined
这个提示是什么意思?
我写的插件包含一个动画效果marginTop,但是却不能设置,为什么
//代码
(function($){
$.fn.newsScroll = function(options){
var dft = {
'speed': '600', //滚动速度
'time' : '3000' //每次滚动的时间
};
var opts = $.extend(dft, options);
var setTime;
var scrollSpeed = opts.speed;
var scrollTime = opts.titme;
function newsScroll(){
var newsHeight = $(this).children().eq(0).height(); //获取父元素第一个子元素的高度,为父元素向上移动做准备;
$(this).animate({ "marginTop": -newsHeight + "px"}, scrollSpeed, function() {
$(this).css("marginTop", "0").children().eq(0).appendTo($(this)); //设置上边距为零,为了下一次移动做准备
});
}
$(this).hover(
function () {
clearInterval(setTime);
},
function(){
setTime = setInterval(newsScroll,scrollTime);
}
).trigger("mouseleave");
}
})(jQuery)
newscroll的指向是window。你可以输出this看看