Sunday 15 July 2012

html - Update td block with javascript -


I have an html table, and I have assigned one of the TD blocks to an ID. There is an image in it. How can I use plain javascript, clear the image which is currently in TD block, and can update it with another image.

This is just jQuery to do something like this:

  function Update Image (Image URL) {$ ("# cellID img"). Et ("src", imageURL); }   

and without pure JS JS:

  function update image (imageURL) {var tdElement = document.getElementById ("cellID"); Var imgElements = tdElement.getElementsByTagName ("IMG"); Var image element = IMGeelments [0]; ImgElement.src = imageURL; }   

or more just:

  function update image (imageURL) {(document.getElementById ("cellID"). GetElementsByTagName ("img") [ 0]). Src = imageURL; }    

No comments:

Post a Comment