Advertisement
Guest User

Entire Code.

a guest
Jul 30th, 2014
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. <html>
  2. <head>
  3. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
  4. <form>
  5. <input type="text" id="textfield" />
  6. </form>
  7. <script type="text/css">
  8. .fade-out {
  9. transition: color 3s ease-in-out;
  10. color: rgba(255,255,255,0); //transparent black
  11. }
  12. </script>
  13. <script type="text/javascript>
  14. window.onload = function(){
  15. var textfieldTimer;
  16.  
  17. $("#textfield").keyup( function(){
  18. clearTimeout(textfieldTimer);
  19. var field = $(this);
  20. textfieldTimer = setTimeout(function(){
  21. field.addClass('fade-out');
  22. textfieldTimer = setTimeout(function(){
  23. field.val('');
  24. console.log(field);
  25. }, 3000
  26. );
  27. }, 5000);
  28. });
  29.  
  30. $("#textfield").keydown(function(){
  31. clearTimeout(textfieldTimer);
  32. $(this).removeClass('fade-out');
  33.  
  34. });
  35. };
  36. </script>
  37.  
  38. </head>
  39. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement