Wednesday, November 25, 2009

How to Add or Remove an Option in HTML Select using JQuery.

Here is the code for appending an Option to a State Dropdown.

JQuery Option ADD
*      id :id of the option
*      state :Name of the state we are adding
*      Dropdown id is :stateDD.

function appendState(id,state){
      $('#stateDD').append($("<option id='+id+' > "+ state + "</option>"));

JQuery Dropdown Option Remove ALL.
*      method will remove all the options Under the dropdown with ID:stateDD.

function clearDD(){

No comments: