Created
November 13, 2015 07:14
-
-
Save Archie22is/4c23d568e163161a17c7 to your computer and use it in GitHub Desktop.
jQuery hover – replace div with another div
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- HTML --> | |
<div class="switch"> | |
<div class="avg_words float_left"> | |
A+ (hover to see score) | |
</div> | |
<div class="avg_num"> | |
AVG = 98.35% | |
</div> | |
</div> | |
<div class="switch"> | |
<div class="avg_words float_left"> | |
A+ (hover to see score) | |
</div> | |
<div class="avg_num"> | |
AVG = 98.35% | |
</div> | |
</div> | |
<div class="switch"> | |
<div class="avg_words float_left"> | |
A+ (hover to see score) | |
</div> | |
<div class="avg_num"> | |
AVG = 98.35% | |
</div> | |
</div> | |
<!-- Style --> | |
<style> | |
.switch { | |
border: 1px solid red; | |
} | |
.avg_num { | |
display: none; | |
} | |
</style> | |
<!-- jQuery --> | |
<script> | |
$('.switch').hover(function() { | |
$(this).find('.avg_words').hide(); | |
$(this).find('.avg_num').show(); | |
}, function() { | |
$(this).find('.avg_num').hide(); | |
$(this).find('.avg_words').show(); | |
}); | |
</script> | |
<!-- NOTES: The script should be easy to follow. Questions, tweet me: @aatsol --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment