当鼠标悬停在某个 div 上时,我想让 .html 文件中的所有 div 消失。换句话说,是否有类似 $(this),
的所有其他 div 而不是 this?
先感谢您。
最佳答案
尝试
var div_all = $('div'); //refers to all div
div_all.hover(function () {
div_all.not(this).hide(); //hide all div's but not current one
$(this).show(); //$(this) refers to current div and show current div
}, function () {
div_all.hide(); //hide all divs
});
div_all.not(this)
引用除悬停的 div 之外的所有 div。
引用资料
关于javascript - 如何选择除我在 jquery 中悬停的元素之外的所有元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20174636/