I want to hover 3 item at a time. when i will put cursor one of them. It should hover other two item.
please can help me anyone. i want to do this with javascript. I have make a model but it is not good. i want to use with function so i can use this again and again. please help me.
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<style type="text/css">
.boxes {
float: left;
display: inline;
width:150px;
height:100px
}
.box1 {
width:50px;
padding:10px;
border:1px solid gray;
margin:0px;
height: 20px;
}
.box4 {
display: inline-block;
width:150px;
padding:10px;
border:1px solid gray;
height: 100px;
}
</style>
<script>
$(document).ready(function(){
// box 1
$('.box1').mouseover(function(){
$('.box1').css('background-color', '#F7FE2E');
$('.box4').css('background-color', '#F7FE2E');
$('.hov').css('color', '#0f0');
});
$('.box1').mouseout(function(){
$('.box1').css('background-color', '#FFF');
$('.box4').css('background-color', '#FFF');
$('.hov').css('color', '#fff');
});
$('.box4').mouseover(function(){
$('.box4').css('background-color', '#F7FE2E');
$('.box1').css('background-color', '#F7FE2E');
$('.hov').css('color', '#0f0');
});
$('.box4').mouseout(function(){
$('.box4').css('background-color', '#FFF');
$('.box1').css('background-color', '#FFF');
$('.hov').css('color', '#fff');
});
});
</script>
</head>
<div class="boxes">
<div class="box1">Box 1</div>
</div>
<div class="box4"><a href="#" class="hov">box4</a> </div>
<br/>
<div class="boxes">
<div class="box1">Box 1</div>
</div>
<div class="box4"><a href="#" class="hov">box4</a> </div>
</body>
</html>
If you group your divs by parent divs, you can use the HTML structure to determine what to highlight. I don’t know your exact usage model, but something like this:
And then in your jQuery:
Here, I use
.closest()to find what group thedivis in, and then highlight all of the other.hoveritems in that group.Example:
http://jsfiddle.net/jtbowden/HZtVP/3/
If you want your divs to not be physically grouped, there are other ways to do what you want.