I know flex box is an option to change the orders of divs however I am using a bit of jquery instead of installing flexbox for one needed feature
This is the script I am using which works fine when resizing the window
<script type="text/javascript">
$(document).load($(window).bind("resize", listenWidth));
function listenWidth( e ) {
if($(window).width()>910)
{
$(".loginblock").remove().insertAfter($("#step1"));
} else {
$(".loginblock").remove().insertBefore($(".regblock"));
}
}
</script>
Is there a simple way to edit my script to know what size the screen is on load and make the changes needed?
Thanks!
You bind the function on resize... Ok.
You only need to also trigger it onload.
<script type="text/javascript">
$(document).load($(window).bind("resize", listenWidth));
function listenWidth( e ) {
if($(window).width()>910)
{
$(".loginblock").remove().insertAfter($("#step1"));
} else {
$(".loginblock").remove().insertBefore($(".regblock"));
}
}
listenWidth(); // Add this here to execute the funtion onload.
</script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.