<form  >
      <input type="text"  onkeypress="getKey();return false;"  name="keyword" placeholder="搜索明星名称"/>
      <button type="button" onclick="changeKeyword();">搜索</button>
</form> 

   function getKey(){ //网页内按下回车触发
          if(event.keyCode==13)
          {
          changeKeyword(); 
        }
   } 

  在搜索栏里面输入内容后,按回车键执行搜索功能。  注意:在onkeypress函数 后面要加上return false 以屏蔽form表单自己默认的提交行为。

   

相关文章:

  • 2021-08-09
  • 2021-09-07
  • 2022-12-23
  • 2022-12-23
  • 2021-06-07
  • 2021-12-09
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案