我想用jquery清除文本框的默认值。
@Html.TextBox("password", ***@Views.Resource.Password***, new { @class = "cssClass" })发布于 2011-12-15 19:09:15
使用此解决方案:
$(function (){
$("input.cssClass").val('');
});或
$(document).ready(function(){
$("input.cssClass").val('');
});发布于 2011-12-15 19:14:37
您可以使用自定义的html helper来获取texbox的id:
public static class HtmlHelperExtensions
{
public static MvcHtmlString ClientIdFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression)
{
return MvcHtmlString.Create(htmlHelper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldId(ExpressionHelper.GetExpressionText(expression)));
}
}你可以在jQuery中说:
$("#@(Html.ClientIdFor(m => m.Password))").val("");https://stackoverflow.com/questions/8519054
复制相似问题