-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.php
59 lines (59 loc) · 1.22 KB
/
test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" href="assets/user_css/user_css.css">
<style>
.search_resilt{
position: relative;
top: 0;
left: 0;
background-color: red;
width: 100%;
}
.search_resilt a{
display: block;
padding: 2px 5px;
}
</style>
</head>
<body>
<div class="header_menu">
<ul>
<li>
<form action="" method="post">
<input type="text" name="search" id="search" placeholder="Search by name">
<button><i class="fas fa-search-plus"></i></button>
</form>
<div class="search_resilt" id="show-list">
<!-- <a href="#">Link 1</a> -->
</div>
</li>
</ul>
</div>
<script type="text/javascript">
$(document).ready(function(){
$("#search").keyup(function(){
var searchText = $(this).val();
if(searchText != ''){
$.ajax({
url:'action.php',
method:'post',
data:{query:searchText},
success:function(response){
$("#show-list").html(response);
}
});
}else{
$("#show-list").html('');
}
});
$(document).on('click','a',function(){
$("#search").val($(this).text());
$("#show-list").html('');
});
});
</script>
</body>
</html>