<!DOCTYPE html>
<html>
<head>
<title>Search Tool</title>
</head>
<body>
<div class="wrapper">
<div class="container-search">
<h1
>Search Tool</h1>
<div class="container-input">
<input type="text" list="psychology_theories_list" id="psychology_theories_search" class="search-term" placeholder="Search on name, category, tags etc.">
<button type="submit" class="search-button" id="selectTheory">
<i class="fa fa-search"></i>
</button>
<datalist id="psychology_theories_list">
<option value="home" />
<option value="section_1" />
<option value="section_2" />
</datalist>
</div>
<ul class="search-history">
<li>
<span class="text"><a href="#">Memory Biases</a></span>
<a href="#" class="link"></a>
</li>
<li>
<span class="text"><a href="#">Persuasive messages that scare</a></span>
<a href="#" class="link"></a>
</li>
<li>
<span class="text"><a href="#">Increase efforts</a></span>
<a href="#" class="link"></a>
</li>
<li>
<span class="text"><a href="#">Decision making</a></span>
<a href="#" class="link"></a>
</li>
</ul>
</div>
</div>
<script src="https://unpkg.com/aos@next/dist/aos.js"></script>
<script>
AOS.init();
</script>
</body>
</html>
@import url(https://fonts.googleapis.com/css?family=Open+Sans);
$primary: #0000FA;
$accent: #F5F6FD;
body {
background-color: $accent;
font-family: 'Open Sans', serif;
}
.wrapper {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
.container-search {
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
max-width: 617px;
width: 100%;
box-sizing: border-box;
h1 {
color: white;
text-align: center;
color: $primary;
font-weight: bold;
}
.container-input {
display: flex;
flex-direction: row;
width: 100%;
.search-term {
max-width: 585px;
width: 100%;
background-color: white;
border: 2px solid $primary;
border-right: none;
color: $primary;
padding: 5px 5px 5px 25px;
height: 40px;
border-radius: 50px 0 0 50px;
outline: none;
-webkit-appearance: none;
caret-color: #primary;
font-size: 20px;
&::-webkit-calendar-picker-indicator {
display: none;
}
&:focus {
color: $primary;
}
&::placeholder {
color: #A3A3FF;
font-weight: italic;
}
}
.search-button {
width: 70px;
height: 54px;
background: white;
text-align: center;
color: $primary;
border-radius: 0 50px 50px 0;
border: 2px solid $primary;
cursor: pointer;
font-size: 25px;
border-left: none;
}
}
ul.search-history {
list-style-type: none;
padding: 0;
margin: 16px 0 0 0;
width: 100%;
&:hover {
li {
opacity: .5;
}
}
li {
color: $primary;
font-size: 16px;
margin-bottom: 8px;
padding: 12px 24px;
display: flex;
flex-direction: row;
align-items: center;
position: relative;
transition: all .3s ease-in-out;
border-radius: 8px;
&:hover {
opacity: 1;
}
span.text {
position: relative;
z-index: 3;
a {
text-decoration: none;
}
}
a.link {
width: 100%;
height: 40px;
display: block;
position: absolute;
z-index: 2;
left: 0;
}
&:before, &:after {
font-family: 'Font Awesome\ 5 Free';
font-weight: 900;
margin-right: 12px;
transition: all .3s ease-in-out;
}
&:before {
content: '\f1da';
}
&:after {
content: '\f30b';
opacity: 0;
position: absolute;
right: 16px;
}
&:hover {
background: rgba($primary, .1);
&:after {
opacity: 1;
}
}
}
}
}
}
View Compiled
$("#selectTheory").on('click', function () {
var editing_page = $("#psychology_theories_search").val();
if($('#psychology_theories_list option').filter(function(){
return this.value === editing_page;
}).length) {
//send ajax request
alert(editing_page);
}
});