Reputation: 464
I want to create a set of options, that will be appended to every select in grid column
<option> option 1 </option>
<option> option 2 </option>
...
<option> option N </option>
but I don't know how to create a set of elements without parent element.
appending to an empty jquery object doesn't work
var options = $('');
options.append('<option></option>')
Upvotes: 0
Views: 367
Reputation: 8187
var Select = $("body").append("<select><option>...</select>");
//if you don't want that select, remove it. But it could feasibly be your first select added to the page
Select = $("body").remove(Select);
var Options = Select.find("option");
Per you comment you might want to use the
$('select.selectClass').replaceWith(Select);
This will allow you to stick with a parent element.
Upvotes: 2