Reputation: 31
I want to make all divs in a .html file disappear while the mouse is hovering on a certain div. In other words, is there anything like the $(this),
but instead of this for all other divs that?
Thank you in advance.
Upvotes: 1
Views: 67
Reputation: 57105
Try
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)
refers to all divs except the one which is hovered.
Upvotes: 2
Reputation: 2104
$('div').hover(
function(){ $('div').not(this).hide(); },
function(){ $('div').show(); }
);
Upvotes: 2