搜索框的回车事件(搜索内容在另一个页面展示)

功能要求是这样的:

搜索框输入要查询的内容,敲击回车,页面跳转到新的页面,并且搜索的内容也会在新的页面展示;当搜索框获得焦点时,默认的搜索框中的值隐藏,如果没有输入任何内容,搜索框失去焦点后,显式原来的默认value值;代码如下:

<input type="text" name="search_index" id="search_index" onkeydown="entersearch1(event)"  onblur="if(this.value==''){this.value='请搜索...'}" onfocus="if(this.value=='请搜索...'){this.value=''}" value="请搜索..."  />
function jump(){
		 var searchval = $("#search_index").val();
		window.location.href=' http://localhost:8080/primaryBird/html/search.html?'+searchval;
	 }
	 function entersearch1(event){  
		    if (event.keyCode == 13)  
		       {  
		    	jump();  
		       }  
		}  

猜你喜欢

转载自blog.csdn.net/IBLiplus/article/details/81393448
今日推荐