有没有一种方法可以只显示我悬停在其上的框的按钮,而不使用 addclass() 属性并切换可见性。有没有办法做类似 $(this).('.list_remove').fadeIn("200");
正确的方法是什么?
Jquery
(function(){
$('.list_remove').hide();
$(".boxes").hover(
function () {
$('.list_remove').fadeIn("200");
},
function () {
$('.list_remove').fadeOut("200");
}
);
})();
HTML
<div class="boxes">
<input type="button" class="list_remove" value="remove"> </div>
<div class="boxes">
<input type="button" class="list_remove" value="remove">
</div>
最佳答案
您可以指定要搜索的上下文,以便 $('.list_remove', this).fadeIn("200");
将在 .list_remove
后代中淡出.boxes
$(".boxes").hover(
function () {
$('.list_remove', this).fadeIn("200");
},
function () {
$('.list_remove', this).fadeOut("200");
}
);
关于Jquery 与 $this 的混淆,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13966696/