Task: using jQuery to ensure that on some ranges of widths a div window is deleted, on others it is added without loss of content.
Javascript
<script type="text/javascript"> window.onload = function() { window.onresize = insertDiv; insertDiv(); }; function insertDiv(){ var div = $(".test"); var WindowWidth = window.innerWidth; if (WindowWidth <= 500){ $(".test").remove(); } else{ $("header").append(div); } } </script> HTML:
<header> <div class="test"> Рыба </div> </header> The string in the else block does not work.
Probably, I do not quite understand what needs to be saved to the value of a variable, but what to delete. As far as I know now, I saved an array into the variable div , which describes the DOM object, and it’s probably not necessary to add this array, but HTML code.
Be that as it may, what is the reason that the script is not working?
Full source code here (you will need a local server, since I saved the php structure of my source code).
display: none;propertydisplay: none;is conflicting for search engine optimization. - Lateral Glebdisplay: none;CSS propertydisplay: none;. - Hokov Gleb