Browse Source

点击搜索修正

li 7 years ago
parent
commit
e750dd01e7
2 changed files with 22 additions and 23 deletions
  1. 18 21
      js/common.js
  2. 4 2
      js/searchNew.js

+ 18 - 21
js/common.js

@ -31,28 +31,27 @@ $(document).ready(function() {
31 31
	
32 32
	//搜索框跳转页面
33 33
	$("#search").on("click", function() {
34
		var searchContent = $("#searchContent").val();
35
		setTimeout(function(){location.href = "searchNew.html?searchContent=" + encodeURI(searchContent)},300);
36
		
37
	});
38
	$("#search").on("click", function() {
39
		var searchContent = $("#searchContent").val().replace(/^\s*|\s*$/,"");
34
		var searchContent = $.trim($("#searchContent").val());
40 35
		if(searchContent) {
41 36
			wlog("kw", searchContent)
37
			setTimeout(function(){location.href = "searchNew.html?searchContent=" + encodeURI(searchContent)},300);
42 38
		}
43 39
	});
44 40
	//enter绑定时间
45 41
	$("#searchContent").keydown(function(e) {
46 42
		if(e.which == 13) {
47
			var searchContent = $("#searchContent").val();
48
			console.log(searchContent);
43
			var searchContent = $.trim($("#searchContent").val());
44
			if(searchContent)
49 45
			location.href = "searchNew.html?searchContent=" + encodeURI(searchContent);
50 46
		}
51 47
	
52 48
	})
53 49
	$("#hsearchContent").keydown(function(e) {
54 50
		if(e.which == 13) {
55
			var searchContent = $("#hsearchContent").val();
51
			var searchContent = $.trim($("#hsearchContent").val());
52
			if(!searchContent) {
53
				return;
54
			}
56 55
			if($(this).siblings()[0].id=="searchh") {
57 56
				location.href = "/searchNew.html?searchContent=" + encodeURI(searchContent);
58 57
				return;
@ -62,25 +61,23 @@ $(document).ready(function() {
62 61
	})
63 62
	
64 63
	$("#hsearch").on("click", function() {
65
		var searchContent = $("#hsearchContent").val();
66
		setTimeout(function(){
67
			location.href = "searchNew.html?searchContent=" + encodeURI(searchContent);
68
		},300)
69
		
64
		var searchContent = $.trim($("#hsearchContent").val());
65
		if(searchContent) {
66
			wlog("kw", searchContent)
67
			setTimeout(function(){
68
				location.href = "searchNew.html?searchContent=" + encodeURI(searchContent);
69
			},300)
70
		}
70 71
	});
71 72
	$("#searchh").on("click", function() {
72
		var searchContent = $("#hsearchContent").val();
73
		var searchContent = $.trim($("#hsearchContent").val());
74
		if(searchContent)
73 75
		setTimeout(function(){
74 76
			location.href = "/searchNew.html?searchContent=" + encodeURI(searchContent);
75 77
		},300)
76 78
		
77 79
	});
78
	$("#hsearch").on("click", function() {
79
		var searchContent = $("#hsearchContent").val().replace(/^\s*|\s*$/,"");
80
		if(searchContent) {
81
			wlog("kw", searchContent)
82
		}
83
	});
80
	
84 81
	/*向下滚动时,header背景变半透明*/
85 82
	$(document).scroll(function() {
86 83
		var top = $(document).scrollTop();

+ 4 - 2
js/searchNew.js

@ -105,7 +105,8 @@ $(function() {
105 105
	$(".searchsome").keydown(function(e) {
106 106
		if(e.which == 13) {
107 107
			num = $(".liactive").attr("data-id");
108
			keyt =$(".searchsome").val()
108
			keyt =$.trim($(".searchsome").val());
109
			if(!keyt) return;
109 110
			if(num==1){
110 111
				expertBox();
111 112
			}else if(num==2){
@ -124,7 +125,8 @@ $(function() {
124 125
	
125 126
	$(".searchgo").on("click",function(e) {
126 127
		num = $(".liactive").attr("data-id");
127
		keyt =$(".searchsome").val()
128
		keyt =$.trim($(".searchsome").val());
129
		if(!keyt) return;
128 130
		if(num==1){
129 131
			expertBox();
130 132
		}else if(num==2){