I’m new to Javascript. I’m trying to raise the margin of the text only on the desktop version, not on mobile. Could you help me find the problem.
<p id="myID">Lorem ipsum dolor sit amet, prima harum elitr te pri. Vix partiendo sententiae ad. Duo at amet dicam tempor. Numquam ceteros concludaturque in eum, id nec adhuc aliquando scriptorem, has ea consetetur cotidieque consectetuer. In verear neglegentur eam.</p>
<script>
let screenwidth=window.innerWidth;
if (screenwidth > "768px")
{
document.getElementById("myID").style.marginLeft = "150px";
}
else {
document.getElementById("myID").style.marginLeft= "0px";
}
</script>
Unfortunately I couldnt find the problem by myself
>Solution :
Replace "768px" by 768. Must be a number and not a string 🙂