javascript - Jquery always repeat functions -
i have these 2 functions create opacity effect
<script> function trans(id) { $(".pris_"+id).stop().fadeout(1000); $(".pris_"+id).css({ opacity: 0.1}); stop(); } function trans_reverse(id) { $(".pris_"+id).stop().fadein(1000); $(".pris_"+id).css({ opacity: 0.8}); stop(); } </script> <div id="productos_image_soon" class="pris_1" onmouseover="trans('1');"onmouseout="trans_reverse('1');"> product in few time </div>
into div phone call each function , problem when set mouseover div time , in recursive mode sec function execute , after first function , go on executed , effect when mouseover opacity low , when mouseout opacity grow
working ..... here jsfiddle.net/dsesq/
i don´t know why happens, i've tried stop() function problem continues
it makes no sense why setting opacity of element after fading in. utilize fadeto!
function trans(id, opacity) { $(".pris_"+id).stop().fadeto( 1000, opacity); }
and should utilize mouseenter , mouseleave. going weird results having mouse on element going disappear.
your code written as
$(".trigger").on("mouseover mouseout", function(evt){ var opacity = evt.type=="mouseover" ? 1 : .8; $(this).stop().fadeto(1000, opacity); })
javascript jquery jquery-animate fadein
No comments:
Post a Comment