【发布时间】:2016-11-15 02:10:05
【问题描述】:
当在 type="search" 文本字段 action upon pressing X button 上按下“X”按钮时,我看到了类似的检测和分配动作的解决方案。
我想使用 @Html.TextBoxFor(model => model.SearchTerm, new { id = "search-box", type = "search"}。但是,它不能专门在清除按钮“X”单击时触发事件。
到目前为止,我已经成功注册了所有事件:
$('#search-box').on('click', function (e) {
alert(e);
System.Diagnostics.Debug.Write(e.target);
});
任何帮助将不胜感激
【问题讨论】:
-
您的要求是
@Html.TextBoxfor中的'X'按钮,并且每当点击'X'时,文本框都会变为空。对吧? -
@SunilKumar 它会在按下“X”时清除文本框中的文本而没有任何代码,但我的要求是在用户单击“X”按钮时重定向到主页。
标签: html jquery asp.net razor jquery-events