Delete option values in select block in HTML with Javascript -
i need delete option value tags inside select elements this:
<select name="name"> <option value="something1">first</option> <option value="something2">second</option> </select>
so need find way delete value="something" javascript, end :
<select name="name"> <option>first</option> <option>second</option> </select>
how javascript?
find options using
queryselectorall
to remove
attribute
useremoveattribute
var options = document.queryselectorall('[name="name"] option'); for (var = 0, ilen = options.length; < ilen; i++) { options[i].removeattribute('value'); }
<select name="name"> <option value="something1">first</option> <option value="something2">second</option> </select>
Comments
Post a Comment