Skip to content
Advertisement

Creating element with a class

This line of code is not working, how can I create a DOM element and adding it a class instantly?

var notes = document.createElement("div").addClass("notes card-content");

Advertisement

Answer

You could use just jQuery for this :

$("<div/>").addClass("notes card-content");

Hope this helps.

Advertisement