我使用此代码检查char是否包含在字符串中,如果选中true复选框,但它总是返回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);
}
答案 0 :(得分:2)
我猜你真的只是在寻找indexOf
if ( "@Model.VillageAR.IncomeLocation.ToString()".indexOf('1') != -1 ) {
$('#IncomeLocation1').prop('checked', true);
}