Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试清除提交时输入的内容(有效),然后重新关注该字段,以便用户可以再次自动开始输入。
$("#submitMessage").submit(function() { $("#messageText").attr("value", ""); $("#messageText").focus(); })
当我这样做时,该字段被清除,但焦点没有返回给元素。有任何想法吗?
- 编辑 -
我在按钮上调用函数而不是表单本身。切换它时总是很好。
如果页面在提交后重新加载,请将焦点代码添加到 document.ready。