divinedesigns1 Posted August 26, 2015 Share Posted August 26, 2015 how can i go about adding an image in javascript code, if im using innerhtml to display my html text? Link to comment Share on other sites More sharing options...
Ingolme Posted August 26, 2015 Share Posted August 26, 2015 With innerHTML, you would just put the image's HTML: var filename = "image.jpg";element.innerHTML = "<img src='" + filename + "'>"; If you want a different method var img = new Image();img.src = "image.jpg";element.appendChild(img); Link to comment Share on other sites More sharing options...
divinedesigns1 Posted August 26, 2015 Author Share Posted August 26, 2015 With innerHTML, you would just put the image's HTML: var filename = "image.jpg";element.innerHTML = "<img src='" + filename + "'>"; If you want a different method var img = new Image();img.src = "image.jpg";element.appendChild(img); thanks Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now