Reputation: 2599
In my page i have multiple buttons (input type=button) with class ="btnDisabled", every button's value is True or False.
why this code returns always false:
$(document).ready(function () {
$(".btnDisabled").each(function(f,el) {
console.log($(this).val() == "False");
});
});
typeof ($(this).val())
returns string
Upvotes: 2
Views: 414
Reputation: 3838
Taking an example,
<input type="button" class="btnDisabled" value="True" />
<input type="button" class="btnDisabled" value="False" />
In JS :
$(document).ready(function () {
$(".btnDisabled").each(function(f,el) {
console.log($(this).val() == "False");
});
});
Here in console we can see "false" for true button and "true" for false button which is correct. Please refer DEMO HERE if still if you not able to resolve this, Paste your complete code in you post.
Upvotes: 0
Reputation: 1600
try using $.trim()
$.trim($(this).val())=="False"
can you paste your html?
Upvotes: 2