Reputation:
The one I'm talking about is one where I have the code appear literally, a string. How do I combine it with actual code, like <div id="thing">string goes here</div>
?
I've tried making the div and id part of the content inside the (' ')
but it doesn't work. When I do that, the content never gets appended.
Here's the code:
$('#placeToAppendTo').append
('<br><div><input type="text" class="textfield" id="text'+textClicked+'"</div>');
Upvotes: 0
Views: 99
Reputation: 318352
or in jQuery:
$('<div />', {id:'thing', text:'string goes here'});
Upvotes: 1
Reputation: 324820
To get the HTML you presented, you would do something like this:
var elem = document.createElement('div');
elem.id = "thing";
elem.appendChild(document.createTextNode("string goes here"));
I hope this helps, since your question isn't particularly clear.
Upvotes: 4