$(document).ready(function() {
$('form').submit(function(e) {
e.preventDefault();
var answerValue = $('#answer').val();
answerValue = answerValue.toLowerCase();
if (answerValue == 'rafael') {
$('body').append('<span class="notice">Acertou!</span>');
} else {
$('body').append('<span class="notice">Tente novamente!</span>');
}
});
});
.notice {
position:absolute;
top:0;
left:0;
display:block;
width:100%;
background:#fafafa;
font-size:1.4em;
text-align:center;
padding:.5em;
color:#328580;
font-weight:700;
}
body {
background:#335778;
}
* { box-sizing:border-box }
.answer {
padding-left:2em;
text-align:center;
display:block;
margin-bottom:.5em;
font-size:2em;
letter-spacing:8px;
&::first-letter {
position:relative;
margin-right:-3.6em;
}
}
form {
width:320px;
border:1px solid #fafafa;
margin:5em auto 0;
padding:2em;
background:#fafafa;
color:#444;
border-radius:3px;
}
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script></head><body><form><spanclass="answer">
Quem sou eu?
</span>
<input id="answer" type="text" placeholder="Enter Above Word">
<input type="submit" value="submit">
</form>
</body>
</html>
I wanted the progress bar to interact through a hit or error corresponding to a question at each hit a percentage of the bar increases and every error it decreases using the above code!