javascript - window.resize event only fires once -
this question has reply here:
setinterval callback runs once 2 answersi trying execute things on window.resize, can't alert work more once. of code have this:
html:
<head> <meta charset="utf-8"> <script src="jquery-1.11.1.min.js"></script>//i have library in html's file directory <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ window.resize(alert("yolo")); }); </script> </head> <body> ... </body>
i have tried several variations:
window.resize(...) window.on("resize",...) window.one("resize",...) $(window).resize(...) $(window).on("resize",...) $(window).one("resize",...)
none of them work. there else haven't tried???
this gets called 1 time since document.ready consumed on page load.
$(document).ready(function(){ window.resize(alert("yolo")); });
you need attach event handler window window.onresize = function() { alert("yolo"); };
or
$(window).resize(function () {alert("yolo");});
javascript jquery javascript-events resize
No comments:
Post a Comment