Add and Remove Elements | JavaScriptSource

Add and Remove Elements

Dustin Diaz Feb 15, 2008

General

Dynamically create HTML elements with content wrapped within them according to the DOM2 specification. Easy to implement.


Click for demonstration [popup]

Notes

Source Code

Paste this source code into the designated areas.

External file

Paste this code into an external JavaScript file named: addRemoveElements.js


CSS

Paste this code into your external CSS file or in the <style> section within the HEAD section of your HTML document.


Head

Paste this code into the HEAD section of your HTML document.


Body

Paste this code into the BODY section of your HTML document


Leave a Response

(5 comments)

It should work as is. If you keep pressing the button, it will just keep adding more.

Lee Jan 16, 2009

Are there additional examples of use of the script.[br /]I don't see how to expand upon the 4 lines of code in the BODY section.

Jay Rumsey Dec 4, 2008

Thanks for the tip. It's been fixed now.

Lee Jun 26, 2008

Trying the "Send Script" displays a pop-up window with error message[br /][br /]"ERROR: Script add-and-remove-elements.html is missing at /www2/jss/cgi-bin/scriptbot2.cgi line 53."[br /][br /]This seems to be true using any of my browsers

Bob Feb 22, 2008

Cool script. Congratulations!

Vinicius Feb 15, 2008