I need to set the value attribute of the option element equal to the text of the option element itself. This is the code I have currently. For some reason it is concatenating the strings.
Here's the HTML markup.
<select id="ResidentialBuildingType" name="ResidentialBuildingType">
<option>SFD</option>
<option>Test</option>
</select>
Here's the jquery code:
<script>
$(document).ready(function () {
var select = $('#ResidentialBuildingType > option');
$(select).each(function (index) {
console.log(select.text());
});
});
</script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.