Skip to content
-
Mind and Script Mind and Script Mind and Script

Deep Thoughts, Clean Thoughts

Mind and Script Mind and Script Mind and Script

Deep Thoughts, Clean Thoughts

  • Home
  • Life
    • Lifestyle
    • Mental Health
    • Personal Growth
    • Philosophy
    • Professional Growth
    • Psychology
  • Books
  • Writing
    • AI Writing
    • Technical Writing
  • Movies
  • Travel
    • Day Trips
    • Food
    • Itineraries
    • World
  • Technology
  • Home
  • Life
    • Lifestyle
    • Mental Health
    • Personal Growth
    • Philosophy
    • Professional Growth
    • Psychology
  • Books
  • Writing
    • AI Writing
    • Technical Writing
  • Movies
  • Travel
    • Day Trips
    • Food
    • Itineraries
    • World
  • Technology
Close

Search

Mind and Script Mind and Script Mind and Script

Deep Thoughts, Clean Thoughts

Mind and Script Mind and Script Mind and Script

Deep Thoughts, Clean Thoughts

  • Home
  • Life
    • Lifestyle
    • Mental Health
    • Personal Growth
    • Philosophy
    • Professional Growth
    • Psychology
  • Books
  • Writing
    • AI Writing
    • Technical Writing
  • Movies
  • Travel
    • Day Trips
    • Food
    • Itineraries
    • World
  • Technology
  • Home
  • Life
    • Lifestyle
    • Mental Health
    • Personal Growth
    • Philosophy
    • Professional Growth
    • Psychology
  • Books
  • Writing
    • AI Writing
    • Technical Writing
  • Movies
  • Travel
    • Day Trips
    • Food
    • Itineraries
    • World
  • Technology
Close

Search

Dynamically Add or Remove Fields using jQuery or JavaScript

August 7, 2018 2 Min Read
0
1*vzH

Here is a Simple example, how you can have the “Add More” feature in a Form.

I have used Array splice() Method here in this example. The splice() method adds/removes items to/from an array, and returns the removed item(s).

You This Code Snippet uses jQuery, who creates all the magic…!! ;). For CDN Link, click here .

Array .splice()

The splice() method changes the contents of an array by removing existing elements and/or adding new elements.

Syntax

array.splice(index, no of items, item1, ….., itemX);

Parameters

index :: It is a required Parameter of type integer. The integer specifies the position in the array at which the items will be added or removed.

no of items :: It is an optional Parameter of type integer. It specifies how many items to be removed. If you don’t want to remove any items, set it to 0.

item1, …, itemX :: It is an optional Parameter. This sets the item(s) to be added to the array. This can be a single item or multiple items.

Example

Note:: The following examples of .splice() are written in pure JS, no libraries used. But you can use jQuery. I have used jQuery in the final code.

  1. To add a single item to the array:
Add a single item.

2. To add multiple items to the array:

Add multiple items.

3. To remove items from the array:

Remove items.

4. To remove existing and add new item in the array:

Remove existing and add new item.

By now we have covered how .splice() works. So with this I have written the “Add More” Feature. Go through and try out the fiddle to have a complete understanding.

Click on HTML tab to view the HTML Code

Feel free to give your Feedback and suggest if any changes required.

If this helped, applauds welcomed. 🙂 Cheers!!

💡 Mind and Script Weekly

Join other engineers and writers. No spam, just substance.

Disclaimer: This post may contain affiliate links. If you click and buy, we may receive a small commission at no extra cost to you. Read our full disclosure here.

Tags:

HTMLJavaScriptjQuery
Author

Rajesh Mishra

I'm a developer who loves sharing insights, technical how-tos, and lessons learned from the world of code. While much of what I write may not be groundbreaking, I believe in documenting for future me—and for anyone else who might find it useful. Beyond tech, I also dive into life's experiences and moments, reflecting on personal growth and sharing stories that resonate. Whether you're here for practical tips or a fresh perspective on life, I hope you find something meaningful.

Follow Me
Other Articles
Previous

DataTables Usage with AJAX (Create and Update Table)

Next

Ionic 3 for Nearby Places

No Comment! Be the first one.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • Hyderabad Traffic
  • 5 Best Books to Read After a Breakup
  • 5 Movies to Stream This Valentine’s Day If You’re Single
  • Self-Care: A Guide to Solo Valentine’s Day
  • Using GitHub Actions for Google Cloud Run

Recent Comments

  1. Sneha on Smartphones: Friend or Foe?

Important Links

  • Affiliate Disclosure
  • Privacy Policy
  • Terms of Use
© Copyright 2026 — Mind and Script. All rights reserved.