出于好奇,我有一个问题,我在如下所示的表单中有一个 HTML 选择:
<select id="new_office_location_select" name="newList[#].Value1">
<option>New York, US</option>
<option>Stamford, US</option>
<option>London, UK</option>
<option>Sydney, AU</option>
</select>
当我提交表单时,无论我选择哪个选项都会将它的值发送到服务器到我的操作方法,即使我没有为每个选项设置“值”属性。这对我来说很好,我很高兴没有它也能正常工作,但理论上选项元素不需要“值”属性吗?
最佳答案
来自MDN
值(value)
The textual content of this attribute represents the label explaining the option. If it is not defined, its default value is the text content of the element.
关于javascript - html select元素在没有值属性的情况下将值发送到服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27445240/