Showing just one element on hover event jQuery -
Showing just one element on hover event jQuery -
i creating team section. have simple <div> have profile photos of each fellow member , when hover photo shows information. made happen jquery's .hover()
. but, when copied same code guess did. yeah, guys right: shows me info team members.
what want display them 1 1 , when stop hovering content homecoming initial state.
i leave js code below:
<script type="text/javascript"> $('.teammemberphoto').hover(function(){ $('.teammembercircle').hide(); $('.teammemberinfo').show(); }); </script>
edit, added html:
<div class="teammemberscontainer"> <div class="teammember"> <h3 class="teammembername">sarei arlin rodriguez camarillo</h3> <p class="teammemberposition">software developer</p> <div class="teammemberbox"> <div class="teammembercircle" style="background: #52b3d9;"> <img class="teammemberphoto" src="../img/team/1.png" alt="member" > </div> <div class="teammemberinfo"> <h4 class="teamwhat">what in job?</h4> <p class="teaminfocontent">software development</p> <h4 class="teamwhat"> why ?</h4> <p class="teaminfocontent">currently, work in software development 1 of fulfilling things have done , has given me great personal , professional satisfaction.</p> <h4 class="teamwhat">what fun?</h4> <p class="teaminfocontent">i have great passion world of technology , telecommunications , love discovering , learning new realm.</p> </div> </div> </div> </div> </div>
thanks in advance.
what happens javascript code selects elements class teammemberphoto , puts hover function on it, hides -all- elements (in whole document, not ones within <div>) have class teammembercircle , shows elements class teammemberinfo.
a solution search within this
element, defined "current" element event handler functions. need set within $(window).load(function(){ ... });
ensure page has been loaded, before changing dom tree.
here working version javascript:
<script type="text/javascript"> $(window).load(function(){ $('.teammemberbox').hover( function(){ $('.teammembercircle', this).hide(); $('.teammemberinfo', this).show(); }, function(){ $('.teammembercircle', this).show(); $('.teammemberinfo', this).hide(); } ); }); </script>
also wanted code allow state homecoming initial state. hence added sec parameter .hover() takes (first one: "handlerin", sec is: "handlerout"). handler flips state original state.
a working version of sample code can found at: http://jsfiddle.net/jkt4b68v/1
note: can find official documentation of .hover()
@ http://api.jquery.com/hover/. api changes increasing revision of jquery should have @ official page, because there lot of old examples in wild utilize e.g. deprecated functions cause problems.
jquery hover jquery-hover
Comments
Post a Comment