You can create separate tags using the .jquery()
method. And create child tags by using the .append()
method. As jQuery supports chaining, you can also apply CSS in two ways.
Either specify it in the class or just call .attr()
:
var lTag = jQuery("")
.appendTo(".div_class").html(data.productDisplayName);
var aHref = jQuery('',{
}).appendTo(lTag).attr("href", data.mediumImageURL);
jQuery('',{
}).appendTo(aHref).attr("src", data.mediumImageURL).attr("alt", data.altText);
Firstly I am appending a list tag to my div tag and inserting JSON data into it. Next, I am creating a child tag of list, provided some attribute. I have assigned the value to a variable, so that it would be easy for me to append it.