我有一个带有选项的简单表单。我知道有一种更好的方法来存储和解析字符串以将其存储为数字。
<html>
<select id="values">
<option value="1"></option>
</select>
</html>
js:
var value = $('#values').parseInt(10);
最佳答案
您必须先使用.val()
来获取值。
// + used to cast string to number
var value = +$('#values').val();
关于javascript - 将输入存储到变量的最简单方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22734502/