Monday, July 17, 2006

jQuery Plugin: addOption

New plugin: addOption allows you to add items to a select dropdown list via jQuery.

2 comments:

Kevin said...

I tried using the code with Safari and the addOption method failed. I modified the code a little to work with Firefox, Safari, Opera and IE.

Changed the following:

var option = document.createElement("option");
option.value = value;
option.text = text;
this.options.add(option);

to

var option = document.createElement("option"); if($.browser.mozilla){
option.value = value;
option.text = text;
this.options.add(option);
} else {
this.add(option);
option.innerText = text;
option.value = value;
}

Sam said...

The latest version works with Safari.