If any method so that as soon as the user reaches 1024px, the function starts its work? For example, $(window).on('resizeEnd', function(){} will work?
|
1 answer
So earn:
$(document).ready(function(){ var started = false; if (document.documentElement.clientWidth > 1023 && !start) { // Код, который нужно исполнить started = true; } $(window).resize(function() { if (document.documentElement.clientWidth > 1023 && !start) { // Код, который нужно исполнить started = true; } }); }); Just consider one thing: if you expand the screen further, the code will be executed again and again and if it is not needed, the variable started will help.
UPD. Completed the function. Now it can work before resizing when conditions are met. If there is a lot of executable code, then it is possible to make repeating fragments in a separate function.
- Thank you! I really need the opposite - when it is less than, but this is not important. Will the code work correctly in Chrome and Mozille? - Nikita Shchypylov
- in all browsers will work - MasterAlex
- Thanks again - Nikita Shchypylov
- Sorry, a little not so work. The user will not change the resolution manually, but the function will work if I manually change the screen resolution. What should I do in this case? - Nikita Shchypylov
- @NikitaShchipilov, that is, it is necessary that the function also work immediately, with the necessary resolution? - MasterAlex
|
css? - MasterAlex