Javascript examples for jQuery Method and Property:append
Add a class to an element created with javascript
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.js"></script> <style id="compiled-css" type="text/css"> .your-class {/*from www . java 2 s .c o m*/ color: orange; } </style> <script type="text/javascript"> $(window).load(function(){ $(".an-element").append("<div class='your-class'>Test</div>"); }); </script> </head> <body> <div class="an-element"></div> </body> </html>