document.getElementById("placehere").appendChild(elem);
not
document.getElementById("placehere").appendChild("elem");
and use the below to set the source
elem.src="https://stackoverflow.com/questions/7802744/images/hydrangeas.jpg";
More Related Contents:
- How do I set/unset a cookie with jQuery?
- Executing elements inserted with .innerHTML
- How to stop event propagation with inline onclick attribute?
- document.createElement(“script”) synchronously
- Firing event on DOM attribute change
- How to expose IFrame’s DOM using jQuery?
- How can I simulate a click to an anchor tag?
- How To Wrap / Surround Highlighted Text With An Element
- Finding line-wraps
- Get child node index
- Getting value of HTML Checkbox from onclick/onchange events
- Check if option is selected with jQuery, if not select a default
- Select all elements with a “data-xxx” attribute without using jQuery
- DOM refresh on long running function
- Finding DOM node index
- change html text from link with jquery
- Remove specific HTML tag with its content from javascript string
- how to compare two elements in jquery [duplicate]
- How do I wrap a text selection from window.getSelection().getRangeAt(0) with an html tag?
- forEach method of Node.childNodes?
- Getting HTML elements by their attribute names
- Display DIV at Cursor Position in Textarea [duplicate]
- Get immediate first child element
- How can I replace one class with another on all elements, using just the DOM?
- Is there a way to know if a link/script is still pending or has it failed
- How to append a childnode to a specific position
- Simple way to get element by id within a div tag?
- How can I detect a Scrollbar presence ( using Javascript ) in HTML iFrame?
- Getting width & height of an image with filereader
- Manually dispatchEvent DOMContentLoaded