Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
- <form>
- <input type="text" id="textfield" />
- </form>
- <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>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement