Any other way of writing this?
$("#list option:eq(24), #list option:eq(10),
#list option:eq(26)")
.attr("selected", "selected");
Any other way of writing this?
$("#list option:eq(24), #list option:eq(10),
#list option:eq(26)")
.attr("selected", "selected");
Try this:
$("#list option").filter(function (index) {
return index == 10 || index == 24 || index == 26;
}).attr("selected", "selected");
Or this:
$("#list option").filter(":eq(10), :eq(24), :eq(26)")
.attr("selected", "selected");
Untested, so handle with care.
Maybe:
$("#list option").filter(function(val, i) {
return [10,24,26].indexOf(i) + 1;
}).attr("selected", "selected");