我想从同一类中的文本字段的最高值中获取值 我尝试过制作这样的脚本,但它不起作用。
<input class="resbobot" name="BobotY2" id="BobotY2" type="text"value="100">
<input class="resbobot" name="BobotY3" id="BobotY3" type="text"value="80">
<input class="resbobot" name="BobotY4" id="BobotY4" type="text"value="70">
JS
$(".resbobot").each(function() {
if ($(this).val()===100) {
alert($(this).val());
}
最佳答案
===
运算符比较值和类型。您的代码正在将字符串文字“100”与数字 100 进行比较。您可以使用 ==
运算符忽略类型或使用 parseInt(..)
作为 @RGS建议。
关于javascript - 如何在同一类、id 和名称中的字段中获取最高值文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25292912/