jquery提交搜索查询并显示键入的文本
空白我有一个这样的表单设置:jquery提交搜索查询并显示键入的文本,jquery,Jquery,空白我有一个这样的表单设置: <form id="search"> <input id="searchbox" type="text" size="40" placeholder="your search.." /> </form> 现在,如果我在#搜索框中键入任何内容,键入的文本不会显示,因为e.preventDefault()我猜,但当我按enter键时,它会执行hitParse()fine n发送空白查询n所有这些。但是如果我删除prevent
<form id="search">
<input id="searchbox" type="text" size="40" placeholder="your search.." />
</form>
现在,如果我在
#搜索框
中键入任何内容,键入的文本不会显示,因为e.preventDefault()
我猜,但当我按enter键时,它会执行hitParse()
fine n发送空白查询n所有这些。但是如果我删除preventDefault(),那么它会很好地显示类型化文本,但是hitParse()不会执行。如何实现这两种功能:显示键入的文本并访问该文本,当按下enter hitParse()时,使用实际键入的查询将preventDefault
移动到if语句中
$('#searchbox').keypress(function (e)
{
if (e.which == 13)
{
e.preventDefault();
hitParse();
}
});
function hitParse(){
// here parse api posts query to parse.com servers
}
$('#searchbox').keypress(function (e)
{
if (e.which == 13)
{
e.preventDefault();
hitParse();
}
});
function hitParse(){
// here parse api posts query to parse.com servers
}