English 中文(简体)
穿透钥匙的中上下装页
原标题:Stop reloading page with Enter Key

我在网页顶上有一个搜索箱,当用户击中邻近的纽特时,可以打电话。 我试图更新输入标号,以便当用户打上进入钥匙时,印有线虫的Java 号成“没有 重载该页。 问题在于该网页不断重载。 我最近试图:

$("searchText").bind( keyup , function(event){ 
  if(event.keyCode == 13){ 
    event.preventDefault();
    $("#buttonSrch").click(); 
    return false;
  }
});

<input type= search  id= searchText  />
<input type= button  id= buttonSrch  onclick="search(document.getElementById( searchText ))" value= Search  />
最佳回答

纽约总部 大会和会议管理部印发 假设<代码>form有searchForm:

$("#searchForm").submit(function() {
    search($("#searchText").get(0));
    return false;
});

< Try it out.

也可以用简便的Java:

document.getElementById( searchForm ).addEventListener( submit , function(e) {
    search(document.getElementById( searchText ));
    e.preventDefault();
}, false);
问题回答

我知道它很晚,但我与你一样陷入同样的问题。 它为我工作的是使用“压力”而不是约束。

$( #searchText ).keypress(function (e) {                                       
       if (e.which == 13) {
            e.preventDefault();
            //do something   
       }
});

增加onSubmit=“return false; on the form tag

<form onSubmit="return false;">
/* form elements here */
</form>`

选择人没有<代码>#。 引言

<input type= text  id= searchText  />

JS

$("#searchText").bind( keyup , function(event){ 
  if(event.keyCode == 13){ 
    event.preventDefault();
    //$("#buttonSrch").click(); 
    search(this.value);
  }
});
 $( #seachForm ).submit(function(e){
      e.preventDefault();
      //do something
 });

你们可以把形式行动归为 j语:避免(0);这样,形式就没有固定职位/目标,这样一页就获得了复读。

$(document).ready(function () {
  $( #form1 ).attr( action ,  javascript:void(0); );
});

Just use the "action" attribute in <form> tag. Like this

<form action="#">   // your content     </form>
$("searchText").keypress(function(event){ 
  if(event.keyCode == 13){ 
    $("#buttonSrch").click(); 
    return false;
  }
});

贵国联合材料是否立即执行,或已准备好文件? 如果该文件没有准备好,则在你重新试图打电话bind<<>code>时,就存在顿胜。

This is what ended up working for me. Please note that my struggle was to find the object that triggered the form submit:

$( #missingStaff ).submit(function (e) {
e.preventDefault();
var comment = $(document.activeElement)[0];
submitComments(comment);

});

仅需要补充:

<form @submit.prevent="search">

无论什么功能都触发搜索。 当我要求查询<代码>search( func)时。 这就是为什么:@submit.prevent=“search”

async search() {
  let yuyu = document.getElementById( search ).value
  console.log( lsd , yuyu)
  try {
    let newRecipes = await this.$axios.$get(
      `/api/videosset/?user=&id=&title=${yuyu}&price=&category=`
    )
    this.$store.commit( CHANGE_NAV_LAYOUT , newRecipes)
  } catch (e) {
    console.log(e)
  }
},




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签