I now want to set an element with <p class=""></p>, but
var p=$('<p></p>').attr({ 'class':""});
The <p class></p> attribute set in this way is empty, and escaping has no effect. Maybe there is something wrong with my writing.
May I ask for a solution? ~
You can use
.attr('class', null)
or
.removeAttr('class')
You can try this to see if it is the effect you want.
For elements whose attributes are equal to empty strings, the browser will automatically retain only the attributes. What are you planning to do by setting this?
You get <p class>haha</p> which is equivalent to <p class=''>haha</p>