Creating a div element in jQuery
You can use append (to add at last position of parent) or prepend (to add at fist position of parent): Alternatively, you can use the .html() or .add() as mentioned in a different answer.
You can use append (to add at last position of parent) or prepend (to add at fist position of parent): Alternatively, you can use the .html() or .add() as mentioned in a different answer.
The first option gives you more flexibilty: And of course .html(‘*’) overrides the content while .append(‘*’) doesn’t, but I guess, this wasn’t your question. Another good practice is prefixing your jQuery variables with $:Is there any specific reason behind using $ with variable in jQuery Placing quotes around the “class” property name will make it more compatible with less flexible browsers.