Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery将MVC中的所有索引Id作为目标_Jquery_Razor_Asp.net Mvc 5 - Fatal编程技术网

Jquery将MVC中的所有索引Id作为目标

Jquery将MVC中的所有索引Id作为目标,jquery,razor,asp.net-mvc-5,Jquery,Razor,Asp.net Mvc 5,我不知道该调用什么,也不知道这个词的正确含义,但我希望我的索引字段在for循环中为电话号码添加Jquery掩码。我无法在Jquery中定位所有电话的Id 这是我的代码集: for (int i = 0; i < Model.AdultCount; i++) { <div class="form-group"> @Html.LabelFor(model => model.CellPhone, htmlAttributes: new { @class

我不知道该调用什么,也不知道这个词的正确含义,但我希望我的索引字段在for循环中为电话号码添加Jquery掩码。我无法在Jquery中定位所有电话的Id

这是我的代码集:

for (int i = 0; i < Model.AdultCount; i++)
{
    <div class="form-group">
         @Html.LabelFor(model => model.CellPhone, htmlAttributes: new { @class = "control-label col-md-2" })
         <div class="col-md-6">
             @Html.EditorFor(model => model.getAttendeeLists[i].CellPhone, new { htmlAttributes = new { @class = "form-control thisisCp"} })
             @Html.ValidationMessageFor(model => model.getAttendeeLists[i].CellPhone, "", new { @class = "text-danger" })
        </div>
    </div>
}
for(int i=0;imodel.mobile,htmlAttributes:new{@class=“controllabel col-md-2”})
@EditorFor(model=>model.getAttendeeList[i]。手机,新的{htmlAttributes=new{@class=“form control thisisCp”})
@Html.ValidationMessageFor(model=>model.getAttendeeLists[i].mobile,“,new{@class=“text danger”})
}
在这里,我尝试在EditorFor中添加一个要调用的类,但没有成功,无法正常工作

@section Scripts {   
    @Scripts.Render("~/jquerymask") 
@Scripts.Render("~/bundles/jqueryui")
@Scripts.Render("~/bundles/jqueryval")
    <script>
        $(".thisisCp").mask("?(9999)999-9999");
    </script>
}
@节脚本{
@Scripts.Render(“~/jquerymask”)
@Scripts.Render(“~/bundles/jqueryui”)
@Scripts.Render(“~/bundles/jqueryval”)
$(“.thisisCp”).mask(“?(9999)999-9999”);
}

你也包括了
jquery-{version}.js
?作为旁注,你的
@Html.LabelFor()
必须是
@Html.LabelFor(model=>model.getAttendeeLists[i].mobile)
顺便说一句@StephenMuecke谢谢你在我上一篇文章中的帮助,刚刚领先了一步。是的,我添加了Jquery版本,你在使用哪个插件?您是否为其包含css文件(如果适用)?请注意,它在中运行良好(尽管不确定为什么在掩码中包含