假设我有<input id="inpID" type="number" min="1" max="5" value="3"></input>
这段代码是否合法:
$("#inpID").val('');
并且它在不同的环境/浏览器中实际运作吗?
答案 0 :(得分:1)
从这里采取:http://www.w3.org/TR/html5/forms.html#number-state-(type=number)
If the element is mutable, the user agent should allow the user to change the number represented by its value, as obtained from applying the rules for parsing floating-point number values to it. User agents must not allow the user to set the value to a non-empty string that is not a valid floating-point number.
我读到的是,是的,可以使用空字符串。