I'm trying to insert javascript variable value in html element inside javascript.. But it's not working properly.. following are my code..
 window.onload = function() {
    var image=document.getElementById('img').value;
        var img = '<div id="pic"><img src="image" width="200" height="108" /><p></p></div>';
      }
This is the function. Here i'm getting image in variable image.. i'm trying to assign this image to in one div id pic.. there i'm assigning src="image" which i got in var image.. But its not working..
You need to insert the value into the string:
var img = '<div id="pic"><img src="' + image + '" width="200" height="108" /><p></p></div>';
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With