Reputation: 2176
I have to build html elements to make my webpage.
var container_item_data = $('<div>').attr('class', 'item_data');
var item_name = $('h4').append('weeee');
container_item_data.append(item_name, 'doooo');
$('#products').append(container_item_data);
But I only get 'doooo' string inside the container_item_data. How can I make it work?
Upvotes: 1
Views: 37
Reputation: 8065
I think you forgot the arrow brackets around the h4
tag. Change your var item_name
line to this:
var item_name = $('<h4>').append('weeee');
Here's a fiddle I made to help explain:
https://jsfiddle.net/qe1862ju/
Upvotes: 1