so i’m trying to do a mouseover with just javascript so that the image doesn’t really show up for seo i set it up in html first to get the css right and am making everything appear with document.write so it can be generated with javascript (my js knowledge is way limited). so with html i am making things with
<img src="img/brokenarrowwear-googleplus.png" onmouseover="this.src='img/brokenarrowwear-google-circle.png';" onmouseout="this.src='img/brokenarrowwear-googleplus.png';"/>
but since it uses “” and ” it doesn’t really work. I tried doing it as
document.write(' <img src="img/brokenarrowwear-googleplus.png" onmouseover="this.src=' + 'img/brokenarrowwear-google-circle.png' + ';" onmouseout="this.src=' + 'img/brokenarrowwear-googleplus.png' + ';"/> ')
but that didn’t really work either. does anyone know how i can do pure javascript? I found
$("img.image-1").mouseenter(function () {
$(this).replaceWith($('<img src="~/Content/images/prosecutor_tile_b.jpg">'));
});
but I don’t think it will work.
3
Answers
Simple inline pure Javascript solution:
The text says “image1” and on mouseover the text in the image will say “image2”
Maybe this can help:
The function pictureChange:
The problem is not the script. I see it in the script source, but I’m not seeing it in the rendered html, actually the whole img tag is missing. Meaning You have some type of rendering issue or another script removed it.
Let’s see if it’s related to the inline javascript and escaping with backslashes doesn’t work: remove the onmouseover and onmouseout attributes from the google img, give it an id=”googlelogo” and add the following script at the end of your body: