在ASP.NET RadioButtonList ListItem上设置CSS类
发布时间:2020-07-03 11:36:04 所属栏目:asp.Net 来源:互联网
导读:有没有办法在单选按钮列表中的输入项上设置CSS类?我想在jQuery中通过类来引用这些表单值。 给定一个ASP.NET RadioButtonList与ListItems上设置的类: asp:RadioButtonList ID=RadioButtonList runat=server asp:ListItem class=myClass Text=Yes Val
有没有办法在单选按钮列表中的输入项上设置CSS类?我想在jQuery中通过类来引用这些表单值。 给定一个ASP.NET RadioButtonList与ListItems上设置的类: <asp:RadioButtonList ID="RadioButtonList" runat="server"> <asp:ListItem class="myClass" Text="Yes" Value="1" /> <asp:ListItem class="myClass" Text="No" Value="0" /> </asp:RadioButtonList> 将呈现为: <span id="RadioButtonList" class="radioButtonListField myClass"> <span class="myClass"> <input id="RadioButtonList_0" type="radio" value="1" name="RadioButtonList"/> <label for="RadioButtonList_0">Yes</label> </span> <span class="myClass"> <input id="RadioButtonList_1" type="radio" value="0" name="RadioButtonList"/> <label for="RadioButtonList_1">No</label> </span> </span> 不幸的是,“myClass”类会添加到< span>包含单选按钮项,而不是< input>本身。我怎么可能让它看起来像这样: <span id="RadioButtonList" class="radioButtonListField myClass"> <span> <input id="RadioButtonList_0" class="myClass" type="radio" value="1" name="RadioButtonList"/> <label for="RadioButtonList_0">Yes</label> </span> <span> <input id="RadioButtonList_1" class="myClass" type="radio" value="0" name="RadioButtonList"/> <label for="RadioButtonList_1">No</label> </span> </span> (这甚至不涉及将类添加到动态绑定的RadioButtonLists的问题。) 解决方法是的,RadioButtonList呈现可怕的HTML。无论如何,它仍然很容易让他们从jQuery。 尝试 $('span.myclass input:radio') 上面将获得跨’myclass’类中的所有单选按钮。 (编辑:大庆站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-core – 在asp.net vnext中使用Startup.cs中的Conf
- WPF 增加合计一栏
- ASP.Net 2中的上传文件在哪里?
- asp.net-mvc – MVC 3布局页面,Razor模板和下拉列表
- asp.net-mvc-4 – 如何在asp.net MVC4查看页面中包含javasc
- asp.net – 更改事件和IE8的jQuery问题
- asp.net-mvc – mvc razor @helper可以返回非编码标签吗?
- asp.net – jquery getJson没有将任何值传递给控制器
- asp.net-mvc – 如何在ASP.NET MVC4中使用具有唯一标识符UR
- asp.net使用H5新特性实现异步上传的示例
推荐文章
站长推荐
- asp.net – 如何在南希显示我的404页面?
- 在ASP.NET MVC中动态地从数据库生成CSS文件
- asp.net-mvc – Asp .Net Core – 无法安装Micro
- 使用SharpZipLib压缩打包多个内存中的文件
- asp.net-mvc – DotNetOpenAuth在ASP.NET MVC中的
- asp.net-mvc – 带有asp.net mvc 4和EntityFrame
- asp.net – 绑定ListView InsertItemTemplate中的
- asp.net – 增加IIS7 / Win7 Pro上的最大上传文件
- asp.net-mvc – 文件上传MVC
- asp.net-mvc – LiveReload ASP.net MVC Web应用
热点阅读