Add “option” to “select” element using JQuery

The following example shows adding “option” to “selelct” element using JQuery


$("#id").append(
          $("<option></option>").attr("value", '0').text('Please Select')
         ).hide().show();

Note that .hide().show() is a trick that used to refresh the select box cause not all browser refresh select automatically after adding new option.

Leave a comment