ASP.NET MVC 使用带有短横线的html Attributes(转载)

我们常常需要一个文本框来输入用户名,在asp.net mvc 中可以使用 TextBoxFor。有时候我们想为这个文本框添加一些特性,比如 html5 的data-,如果直接写data-是会提示错误的。

我遇到这个错误是使用easyui,在TextBoxFor中添加html Attributes时遇到的,如下图所示:

解决方法

可以使用下划线(_)代替短横线(-),上例中则应该写成data_options,Html helper会自动将下划线处理成短横线。

【jQuery】清空表单内容

function  resertForm(){
2     $(':input','#formId') 
3     .not(':button, :submit, :reset, :hidden') 
4     .val('') 
5     .removeAttr('checked') 
6     .removeAttr('selected');
7 }
复制代码
原文地址:https://www.cnblogs.com/Alex80/p/7764026.html