I want to create following elements
<span>
<h3>Title</h3>
<p>This is paragraph</p>
</span>
I want to do above using jquery in following manner.
$('<span />', {
}).appendTo('body');
How can I create children element of span with above method?
$('<span />', {})
.append($('<h3/>').text('Tite'))
.append($('</p>').text('para'))
.appendTo('body');
$('<span />', {}) .append(function () { return '<h3>Title</h3><p>This is paragraph</p>'; }).appendTo('body');
$('<span />', {}) .append($('<h3/>').text('Tite'), $('</p>').text('para')) .appendTo('body');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.