I am working on HTML code that currently displays an image. The code looks like this:
<div>
<img id="wm01" alt="PP" title="PP" u="image" src="theImages/wm01.jpg" />
</div>
My goal is to show a different image based on the screen size. To start, I use CSS to hide the image:
#wm01 {
display: none;
}
Next, in the BODY of my document, I add the following JavaScript code:
var w = window,
d = document,
e = d.documentElement,
g = d.getElementsByTagName('body')[0],
x = w.innerWidth || e.clientWidth || g.clientWidth,
y = w.innerHeight|| e.clientHeight|| g.clientHeight;
if (x<568) {
//alert(x);
document.getElementById("wm01").src="theImages/wm01_app.jpg";
document.getElementById("wm01").style.display = "block";
}
else {
document.getElementById("wm01").src="theImages/wm01.jpg";
document.getElementById("wm01").style.display = "block";
}
Unfortunately, the image is not showing up on any screen size. How can I troubleshoot and fix this issue?