I search to know how place a new select element at the second place of a select list
The hierarchy:
My function :
function classAppend(){
$('#email').append(
$('<option></option>').val('').addClass('new_address_mail').html("Add")
);
}
Some one know what is the option?
Try this:
$('#email option:first').after($('<option />', { "value": '', text: 'My new option', class: 'new_address_mail' }));
You probably have to select the first child of #email
and insert your element with insertAfter
:
$('<option></option>')
.val('')
.addClass('new_address_mail')
.html("Add")
.insertAfter($('#email').children().first());
$("<option value='x'>newly added</option>").insertAfter($("select option:first"));
DEMO
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With