javascript-- changing the innerHTML of an image -


so asked question , i've hit roadblock. stackoverflow community helping me out :)

every time see people changing innerhtml of tag, use document.getelementbyid(id).innerhtml. images not have ids, nor want give each , every 1 of them id.

here code:

function clickimages() { var images = document.getelementsbytagname("img"); for(var = 0; < images.length; i++) {      var delegate = function() { hover(this); };    images[i].onmouseover = delegate; } }  function hover(img) { img.innerhtml = "text!"; } 

the innerhtml doesn't seem it's working; when mouse on image nothing changes.

thanks in advance! let me know if can clarify!

an image replaced element, there no innerhtml replace.

based on comment, if want add html adjacent image, this:

img.insertadjacenthtml('afterend', 'html code'); 

you change 'afterend' 'beforebegin' if wanted add html before image.

writing on image more complicated , require positioning element above transparent background, or using image background of element, or variety of other similar techniques.


Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -