I Use this Code to check a char is contain in string if true checked checkbox but it always return true.why??
//it is mvc project and after execution it become like this:if ($("123:contains(1)"))
if ($("@Model.VillageAR.IncomeLocation.ToString():contains(1)"))
{
$('#IncomeLocation1').attr('checked', true);
}
php-dev
7,1864 gold badges27 silver badges39 bronze badges
asked Jan 25, 2014 at 21:16
Vahid Akbari
1897 silver badges25 bronze badges
-
String manipulations have nothing to do with jQuery...Derek 朕會功夫– Derek 朕會功夫2014年01月25日 21:39:33 +00:00Commented Jan 25, 2014 at 21:39
1 Answer 1
I'm guessing you're really just looking for indexOf
if ( "@Model.VillageAR.IncomeLocation.ToString()".indexOf('1') != -1 ) {
$('#IncomeLocation1').prop('checked', true);
}
answered Jan 25, 2014 at 21:17
adeneo
319k29 gold badges410 silver badges392 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-js