<!DOCTYPE html>
<html>
<head>
<title>ApiProject</title>
<link href="style.css" rel="stylesheet" type="text/css"></link>
<link href="https://fonts.googleapis.com/css?family=Luckiest+Guy" rel="stylesheet"></link>
</head>
<body>
<section>
<h1>WHAT DOES YOUR NAME SAY ABOUT YOUR PERSONALITY?</h1>
<div class="centerDiv">
<div class="details">
<label>ENTER YOUR NAME</label><br />
<input id="nameid" name="" type="text" />
</div>
<div class="imgdiv">
<img class="imgchange" height="200" src="Enter your image name with extension" width="200" />
</div>
<button> Click Me</button>
</div>
</section>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
$('button').click(function(){
const name = $('#nameid').val();
/*alert(name);*/
$('.imgchange').attr('src',`https://joeschmoe.io/api/v1/${name}`);
const b = $('.imgchange');
console.log(b);
});
});
</script>
</body>
</html>
---------------------------------------------------
CSS FILE
*{padding: 0; margin: 0; box-sizing: border-box; font-family: 'Luckiest Guy', cursive;}
section{width: 100%; height: 100vh; display: flex; justify-content: center; flex-direction: column; align-items: center; background: #2ed573}
section h1{ text-shadow: 2px 5px 5px #2f3542; word-spacing: 10px; margin-bottom: 15px;
font-size:2.5rem; text-transform: uppercase; letter-spacing: 2px; color: white;}
.centerDiv{ width: 60%; height: 450px; box-shadow:2px 2px 2px 5px white; display: flex;
flex-direction: column; align-items: center; justify-content: center; background: #57606f; color: white;}
.details{ text-align: center; text-transform: uppercase; }
.details label{font-size: 1.4rem;}
.details input { padding: 10px; background-color: #ff6b81; color: white; text-align: center;}
.details input[type=text]:focus {
border: 3px solid #555;
}
.imgdiv {margin: 30px 0;}
button {
background: #3498db;
width: 180px;
padding: 4px 0;
border-radius: 3px;
color:white;
font-size: 1.2rem;
letter-spacing: 2px;
background-color: darken(#f1c40f, 20%);
}
button:hover {
cursor: pointer;
}
Comments
Post a Comment