Using
DOM Elements Creator plugin :
$.create('option', {'value': 'val'}, 'myText').appendTo('#mySelect');
Using the
Option constructor (not sure about browser support):
$(new Option('myText', 'val')).appendTo('#mySelect');
Using
document.createElement (avoiding extra work parsing HTML with
$("<option></option>")):
$('#mySelect').append($(document.createElement("option")).attr("value","val").text("myText"));
No comments:
Post a Comment