The add() method is used to add an option to a dropdown list. Here in this example we have added an option to the select tag by using the add() method.
option : it is the option value which is to be added into the select tag's option list and this argument is required.
before : it specifies the position of the option value to be added and it is also required while adding some option to the select tag option.
Description of example:
When you will run this HTML page on the browser you will see that it contains only four elements into it.
Now when you will click on the "Add" button it will add one more option to the list named with the "kumar" at the "5" position.
Posted on: January 29, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles