javascript assign image to span with alt text -


i work javascript

i didn't find how can assign image span , add alt text image

i have code :

<a href="testurl" >   <span id="101"></span>                                     </a> 

this code javascript :

var pic = "c:\image1.jpeg";  var img = new image();  img.src=pic ; var defautvalue='10' var nbrinc='('; nbrinc=nbrinc.concat(defautvalue,img,')');   document.getelementbyid("101").innerhtml=nbrinc; 

jsfiddle example: https://jsfiddle.net/dxbv69uq/

var pic = "http://images.visitcanberra.com.au/images/canberra_hero_image.jpg";  var img = new image(); img.onload = function() {     var e = document.createelement("img");     e.setattribute("src", img.src);     e.setattribute("alt", "title");     document.getelementbyid("101").appendchild(e); } img.src=pic; 

Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - IIFE: var vs this - is there any difference? -

ios - Google API (YouTube search): Bad network response -