Avoid repeated .click() in jQuery -
i have jquery script triggers click based on scroll position. want able click element again if user returns top of page contact form hide itself. problem creates loop.
jquery(window).scroll(function (event) { var y = $(this).scrolltop(); if (y > 400) { $("#contactable-inner").click(); $("#contactable-inner").unbind('click');} });
you can go here see working on: http://algk.me
update:
$(window).scroll(function(){ var y = $("body").scrolltop(); var hidden = $('.hidden'); if (y >= 1000 && (hidden.hasclass('visible'))){ hidden.animate({"left":"-1000px"}, "slow").removeclass('visible'); } else { hidden.animate({"left":"0px"}, "slow").addclass('visible'); } });
any idea how work on scroll?
what if used jquery's .show()? instead of simulating click.
jquery(window).scroll(function (event) { var y = $(this).scrolltop(); if (y > 400) { $("#contactable").show(); } else { $("#contactable").hide(); } });
Comments
Post a Comment