Javascript examples for jQuery Method and Property:add
Add a span element
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $("p").add("<br><span>A new span element.</span>").appendTo("p"); });/*w ww .j av a 2 s.c o m*/ }); </script> </head> <body> <button>Add a span element</button> <p>A p element.</p> </body> </html>