1
I created a elemento
javascript:
$("<div />").addClass("placeholder").appendTo(element);
But I can’t give him attributes, how can I do that? I tried the following code, but it doesn’t work:
$(document).ready(function(){
$(".placeholder").addClass("fg-red");
});
If I create it with HTML it works but when I create with Javascript the attempt to add attributes does not work
This is all wrong
addClass(".placeholder")
. You do not need the point before to indicate that it is a class, the functionaddClass
serves exclusively for this.– Renan Gomes
Sorry it’s not the real code I typed by cell phone and in a hurry came out wrong and I didn’t see, sorry
– user45722