Reputation: 3
I have 2 overlapping divs and need the same mousemove event to be executed on both. I cant use nested divs with bubbling effect. How can I do that? I cant use nested divs with bubbling effect.
$(".one").mousemove(function(){
console.log("something")
})
$(".two").mousemove(function(){
console.log("something else")
})
.one{
background-color:red;
position:absolute;
left:0;
top:0;
width:100px;
height:100px;
}
.two{
color:blue;
position:absolute;
left:0;
top:0;
width:100px;
height:100px;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script src="https://code.jquery.com/jquery-3.1.0.js"></script>
<div class="one">
Content one
</div>
<div class="two">
Content two
</div>
</body>
</html>
Thank you.
Upvotes: 0
Views: 614
Reputation: 9470
$(".one").mousemove(function(){
console.log("something");
});
$(".two").mousemove(function(){
console.log("something else");
$(".one").mousemove();
});
.one{
background-color:red;
position:absolute;
left:0;
top:0;
width:100px;
height:100px;
}
.two{
color:blue;
position:absolute;
left:0;
top:0;
width:100px;
height:100px;
opacity: .95;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="one">
Content one
</div>
<div class="two">
Content two
</div>
Upvotes: 3