0

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);
}
1
  • String manipulations have nothing to do with jQuery... Commented Jan 25, 2014 at 21:39

1 Answer 1

2

I'm guessing you're really just looking for indexOf

if ( "@Model.VillageAR.IncomeLocation.ToString()".indexOf('1') != -1 ) {
    $('#IncomeLocation1').prop('checked', true);
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.