Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Simple Textbox assitance Reply To: Simple Textbox assitance

#176912
1595465132
Participant

Alright, so I’ve got JQuery importing first, now I’ve got your code written as such:
<html>
<head>
<script src=”jquery-1.11.1.min.js”></script>
<form>
<input type=”text” id=”textfield” />
</form>
<script src=”//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js”></script>
<script>window.jQuery || document.write(‘<script src=”js/jquery-1.7.2.min.js”><\/script>’)</script>
<script type=”text/css”>
.fade-out {
transition: color 3s ease-in-out;
color: rgba(255,255,255,0); //transparent black
}
</script>
<script type=”text/javascript>
window.onload = function(){
var textfieldTimer;

$("#textfield").keyup( function(){
    clearTimeout(textfieldTimer);
    var field = $(this);
    textfieldTimer = setTimeout(function(){
        field.addClass('fade-out');
        textfieldTimer = setTimeout(function(){
            field.val('');
            console.log(field);
        }, 3000         
        );
    }, 5000);
});

$("#textfield").keydown(function(){
    clearTimeout(textfieldTimer);
    $(this).removeClass('fade-out');

});

};
</script>

</head>
</html>