Add/Remove <span> tag

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Add/Remove <span> tag

Post by JayBird »

I have a form where users can click a button and more form fields are added by using innerHTML.

I would now like to include a "remove" button incase the user adds too many fields.

I can't remove the fields by referencing them by name, as they all have the same name (date[])


So, i am thinking of wrapping each field in a <span> tag with a unique ID.

Im a little unsure how to go about removing the <span> tag and its contents using Javascript.



Thanks

Mark
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

it'd be a removeChild() type action..
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

don't use span... instead you can remove individual form elemnts by removeChild()
Post Reply