javascript - smooth transition with show/hide jquery functions on hover? -


i'm using image map , when part of image hovered show div..(like in website http://jquery-image-map.ssdtutorials.com/) want div appear smooth transitions... here js code

var mapobject = {     hover : function(area, event) {         var id = area.attr('name');         if (event.type == 'mouseover') {             $('.' + id).show();             $('#'+ id).siblings().each(function() {                 if ($(this).is(':visible')) {                     $(this).hide();                 }             });             $('#'+ id).show();         } else {             $('.' + id).hide();             $('#'+ id).hide();             $('#room-0').show();         }     } }; $(function() {      $('area').live('mouseover mouseout', function(event) {         mapobject.hover($(this), event);     });  }); 

can please suggest me changes smooth transitions... in advance! :)

so first of all, unrelated tip - idea update jquery bit (if there isn't depends on old version using). live won't available, instead you'll need replace .on, otherwise it's idea.

secondly, sounds you're looking give hide , show transition. can replace them fadein() , fadeout(). can use toggle @ once (though might misbehave when used hover, because flip crazy).

here's small snippet shows how work:

$(document).ready(function() {          var img = $('img');        $('#show').on('click', function() {     	 img.fadein();    });        $('#hide').on('click', function() {      	img.fadeout();    });        $('#toggle').on('click', function() {    	img.fadetoggle();      });          });
* { font-family: sans-serif; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>    <button id="show"> show me! </button>    <button id="hide"> hide me! </button>    <button id="toggle"> toggle me! </button>    <br>  <br>  <img src="http://www.randomwebsite.com/images/head.jpg" />

of course, shortcut functions use .animate functionality, quite flexible on own. here's link can read more effects , animations in jquery , how can use them


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -