Reputation: 85046
I am trying to use the add function to add an HTML fragment to a div but I can't get it to work. My code:
$('#curveContainer').add('<img src="http://upload.wikimedia.org/wikipedia/commons/f/f0/Blue-dot-5px.png" alt="test" />');
Fiddle here - http://jsfiddle.net/7a86g/4/
Upvotes: 0
Views: 69
Reputation: 164739
You want append()
, not add()
.
From the add()
documentation...
Given a jQuery object that represents a set of DOM elements, the .add() method constructs a new jQuery object from the union of those elements and the ones passed into the method.
append()
will add the new content to the DOM
Fiddle here - http://jsfiddle.net/7a86g/5/
You can also use html()
to completely replace the contents of the matched element.
Upvotes: 5