How can I check whether a option already exist in select by JQuery?
I want to dynamically add options into select and so I need to check whether the option is alread
It's help me :
var key = 'Hallo'; if ( $("#chosen_b option[value='"+key+"']").length == 0 ){ alert("option not exist!"); $('#chosen_b').append(""+key+""); $('#chosen_b').val(key); $('#chosen_b').trigger("chosen:updated"); } });