How To Get Highest Value Text While Field In Same Class, Id And Name?
I want to get value from highest while text field in the same class I have tried to make a script like this but it does not work. == operator to ignore the type or use
parseInt(..)
as @RGS suggested.Solution 2:
$(".resbobot").each(function() {
if(parseInt($(this).val())===100)
{
alert($(this).val());
}
});
You have to check text box value with string data type i.e. ' ' or else with integer data type because you are using equal value and equal type operator.
Demo:
Solution 3:
var max = 0
$(".resbobot").each(function() { if ($(this).val()>max) { max = $(this).val()})
alert(max)
Solution 4:
=== Checks type and value, == checks value. So "100" === 100 returns false where "100" == 100 returns true.
Solution 5:
To find the highest value from the input fields using jQuery, use the following code:
var highestVal = null;
$('.resbobot').each(function(){
var curVal = Number($(this).val());
highestVal = (highestVal === null || highestVal < curVal) ? curVal : highestVal;
});
alert(highestVal);
The above code will work even if the input values are all negative numbers.
Post a Comment for "How To Get Highest Value Text While Field In Same Class, Id And Name?"