javascript - Unbind custom function from element -
i have following code:
$( window ).resize(function() { if (matchmedia('only screen , (min-width: 992px)').matches) { $('#second').parallax(); $('.sketches-1').parallax(); $('#fifth').parallaxfifth(); } else{ //... } }); i wish remove parallax function on mobile devices, how can achieve this?
use:
var parallax = function() { if (matchmedia('only screen , (min-width: 992px)').matches) { $('#second').parallax(); $('.sketches-1').parallax(); $('#fifth').parallaxfifth(); } else{ //... } }; $(window).resize(parallax); //some code here... $(window).off('resize', parallax); if don't want use effect on mobile use:
function ismobile() { /android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(navigator.useragent); } if (!ismobile()) { $(window).resize(parallax); }
Comments
Post a Comment