Skip to content
Advertisement

Passing Attributes to Append function in Jquery Not Working

I am trying to pass attributes to a jquery append function. It appends the html but does not append the attributes. There are no errors shown in the console either. Html Code :

JavaScript

Javascript Code :

JavaScript

I want the HTML to look like

JavaScript

Advertisement

Answer

.append() is a Method which accepts string arguments or a function .append("<p>A</p>", "<p>B</p>") or .append(function() {}); – so you’re passing an invalid Object as argument.

Instead, use $("<HTMLTag>", {...options}) to Create New Elements

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement