抱歉,如果这是基本的。我似乎无法理解$this
。
<div class="product" id="product" onclick="show(this)"></div>
function show(){
$(this).animate({
width:('100%'),
marginTop:top+'px'
}, 600);
}
这不会动画,因为我使用 $(this)
。如何直接读取参数this
?
我不想使用 jquery onclick
事件,但使用这个 html
事件。
最佳答案
放弃内联 JavaScript 并改为使用:
$('#product').click(function() {
$(this).animate({
width: ('100%'),
marginTop: top + 'px'
}, 600);
})
关于javascript - 在 jquery 中将其动画化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59535878/