This question already has an answer here:
- jQuery document.createElement equivalent? 13 answers
How do I create a div
element in jQuery?
</div>
转载于:https://stackoverflow.com/questions/867916/creating-a-div-element-in-jquery
This question already has an answer here:
How do I create a div
element in jQuery?
</div>
转载于:https://stackoverflow.com/questions/867916/creating-a-div-element-in-jquery
You can use append
(to add at last position of parent) or prepend
(to add at fist position of parent):
$('#parent').append('<div>hello</div>');
// or
$('<div>hello</div>').appendTo('#parent');
Alternatively, you can use the .html()
or .add()
as mentioned in a different answer.