I want to create this on my website. The user enters some text into the text field, and after he presses the enter key, the text field will change to a div, and the div will contain text from the text field, and it will be in the same place where the text field was, and the text field will be hidden. Is it possible?
Here is what I have now: HTML:
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-cookie/2.1.3/js.cookie.js"></script>
<input id="name" type="text" class="name" placeholder="What your name?"/>
Javascript (inside HTML file)
<script>
$(document).ready(function(){
var name = Cookies.get('_username');
if (name) {
$('#name').val(name);
}
$('#name').keydown(function(){
var inputName = $('#name').val();
Cookies.set('_username', inputName);
})
});
</script>
CSS
@import url('https://fonts.googleapis.com/css?family=Roboto+Condensed:700');
.name{
font-family: 'Roboto Condensed', sans-serif;
font-size: 3.5vw;
border: 0;
outline:0;
background: transparent;
border-bottom: 2px solid white;
width: 30%;
color:#000000;
position:fixed;
top:60%;
left:50%;
margin-left:10px;
}
source
share