javascript - Making consecutive images only appear after the last disappear while hovering -


in little project of mine have several buttons, when hovered display image in div. after hovering first button, when hovering second first image still there , both images show up.

what do second image appear after first disappeared?

my javascript code:

$(".button").hover(function () {     var in = $(this).attr("id").charat(6);     $('#img'+ in).fadein('slow'); },function() {     var in = $(this).attr("id").charat(6);    $('#img' + in).fadeout('slow'); }); 

this how it, may not work in use case. (if not, please add more detail question.)

note example uses jquery "starts with" selector: ^= re-hide elements id begins letters img

$('img').hide();    $(".button").hover(function () {      var in = $(this).attr("id").charat(6);      $('#img'+ in).fadein('slow');  },function() {      $('[id^=img]').fadeout();  });
div{height:100px;width:200px;border:1px solid orange;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>    <div id="123456f" class="button">    <img id="imgf" src="http://placeimg.com/200/100/nature" />  </div>  <div id="kittenc" class="button">    <img id="imgc" src="http://placeimg.com/200/100/animals" />  </div>


Comments

Popular posts from this blog

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

jsf - "PropertyNotWritableException: Illegal Syntax for Set Operation" error when setting value in bean -

laravel - Undefined property: Illuminate\Pagination\LengthAwarePaginator::$id (View: F:\project\resources\views\admin\carousels\index.blade.php) -