Can I select three IDs with a shorter jQuery script? -
i believe there better way selecting these 3 ids dropdown-list (id 115, 116 , 117):
jquery(document).ready(function($) { var usednames = {}; $("select[name='item_meta[115]'] > option").each(function () { if(usednames[this.text]) { $(this).remove(); } else { usednames[this.text] = this.value; } }); var usednames = {}; $("select[name='item_meta[116]'] > option").each(function () { if(usednames[this.text]) { $(this).remove(); } else { usednames[this.text] = this.value; } }); var usednames = {}; $("select[name='item_meta[117]'] > option").each(function () { if(usednames[this.text]) { $(this).remove(); } else { usednames[this.text] = this.value; } }); });
can make code shorter, , have ids selected under first variable?
you can use attribute starts selector
$("select[name^='item_meta'] > option")
Comments
Post a Comment