Hi
So I have made a search box in footer.html. And it seems to work when clicked in footer.html. But when the footer is loaded into index.html that same search box just sits there. And nothing happens when it is clicked. Perhaps you could tell me if I have put in the JQuery or JS strings in the wrong order or something.
Here is HTML of index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="stylesheet.css">
<script src="https://code.jquery.com/jquery-3.5.1.js"></script>
<script src="https://kit.fontawesome.com/a076d05399.js"></script>
<script
src="https://code.jquery.com/jquery-3.3.1.js"
integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60="
crossorigin="anonymous">
</script>
<title>Document</title>
</head>
<body>
<div id="header"></div>
<ul class="navbar" id="nav" id="exit"></li>
<li><a href="index.html">Home</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
<div class="dummy-text">
<h2>Welcome to a good clinic</h2>
</div>
<section class="Bigpost">
<h1><img src="images.jpg" alt="server graphic">
</h1>
<div id="footer"></div>
</section>
<script src="Javascript.js"></script>
</body>
</html>
Here is footer.html where the same animation works:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="stylesheet.css">
<title>Document</title>
<script src="https://code.jquery.com/jquery-3.5.1.js"></script>
<script src="https://kit.fontawesome.com/a076d05399.js"></script>
</head>
<body>
<div class="footer-container">
<div class="mainfooter">
<div class="socials">
<a href="#"><i class="fa fa-facebook"></i></a>
<a href="#"><i class="fa fa-twitter"></i></a>
<a href="#"><i class="fa fa-dribbble"></i></a>
<a href="#"><i class="fa fa-youtube"></i></a>
<a href="#"><i class="fa fa-tumblr"></i></a>
</div>
<div class=footer 1>
<h2>Adress</h2>
<a href="#">Sagene Allé 30</a>
<a href="#">43012 Oslo</a>
<a href="#">(0047)56890</a>
</div>
<div class=footer 2>
<h2>Contact</h2>
<a href="#">Mail</a>
<a href="#">About</a>
<a href="#">Call us</a>
</div>
<div class=footer 3>
<div class="search-box">
<input type="text" placeholder="Type to search..">
<div class="search-icon">
<i class="fas fa-search"></i>
</div>
<div class="cancel-icon">
<i class="fas fa-times"></i>
</div>
<div class="search-data">
</div>
</div>
</div>
</div>
</div>
<script src="Javascript.js"></script>
</body>
</html>```
Here is CSS for both the documents above:
.footer-container {
background-color: #000080;
display: flex;
position: relative;
width: 100%;
margin-bottom: 0px;
align-items: center;
padding-bottom: 4rem 0 4rem 0;
}
.mainfooter {
width: 100%;
height: 42vh;
justify-content: center;
display: flex;
color: white;
margin: 0 auto;
align-items: center;
background-color: #000080;
position: absolute;
margin-bottom: 0px;
}
.footer {
display: flex;
flex-direction: column;
margin-right: 2rem;
margin-top: 2rem;
}
.footer h2 {
margin-bottom: 1rem;
margin-top: 1rem;
}
.footer a {
color: white;
text-decoration: none;
margin-bottom: 0.5rem;
}
.footer a:hover {
cursor: pointer;
color: greenyellow;
}
CSS for search box inserted in footer:
::selection{
color: #fff;
background: #664AFF;
}
.search-box{
position: relative;
height: 60px;
width: 60px;
border-radius: 50%;
box-shadow: 5px 5px 30px rgba(0,0,0,.2);
transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
.search-box.active{
width: 350px;
}
.search-box input{
width: 100%;
height: 100%;
border: none;
border-radius: 50px;
background: #fff;
outline: none;
padding: 0 60px 0 20px;
font-size: 18px;
opacity: 0;
transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
.search-box input.active{
opacity: 1;
}
.search-box input::placeholder{
color: #a6a6a6;
}
.search-box .search-icon{
position: absolute;
right: 0px;
top: 50%;
transform: translateY(-50%);
height: 60px;
width: 60px;
background: #fff;
border-radius: 50%;
text-align: center;
line-height: 60px;
font-size: 22px;
color: #664AFF;
cursor: pointer;
z-index: 1;
transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
.search-box .search-icon.active{
right: 5px;
height: 50px;
line-height: 50px;
width: 50px;
font-size: 20px;
background: #664AFF;
color: #fff;
transform: translateY(-50%) rotate(360deg);
}
.search-box .cancel-icon{
position: absolute;
right: 20px;
top: 50%;
transform: translateY(-50%);
font-size: 25px;
color: #fff;
cursor: pointer;
transition: all 0.5s 0.2s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
.search-box .cancel-icon.active{
right: -40px;
transform: translateY(-50%) rotate(360deg);
}
.search-box .search-data{
text-align: center;
padding-top: 7px;
color: #fff;
font-size: 18px;
word-wrap: break-word;
}
.search-box .search-data.active{
display: none;
}