Advertisement
JonneOpettaja

jQuery1

Nov 5th, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. <script type="text/javascript">
  2.  
  3. var messageDelay = 2000; // How long to display status messages (in milliseconds)
  4.  
  5.  
  6. // Init the form once the document is ready
  7. $( init );
  8.  
  9.  
  10. // Initialize the form
  11.  
  12. function init() {
  13.  
  14. // Hide the form initially.
  15. // Make submitForm() the form’s submit handler.
  16. // Position the form so it sits in the centre of the browser window.
  17. $('#contactForm').hide().submit( submitForm ).addClass( 'positioned' );
  18.  
  19. // When the "Send us an email" link is clicked:
  20. // 1. Fade the content out
  21. // 2. Display the form
  22. // 3. Move focus to the first field
  23. // 4. Prevent the link being followed
  24.  
  25. $('a[href="#contactForm"]').click( function() {
  26. $('#content').fadeTo( 'slow', .2 );
  27. $('#contactForm').fadeIn( 'slow', function() {
  28. $('#senderName').focus();
  29. } )
  30.  
  31. return false;
  32. } );
  33.  
  34. // When the "Cancel" button is clicked, close the form
  35. $('#cancel').click( function() {
  36. $('#contactForm').fadeOut();
  37. $('#content').fadeTo( 'slow', 1 );
  38. } );
  39.  
  40. // When the "Escape" key is pressed, close the form
  41. $('#contactForm').keydown( function( event ) {
  42. if ( event.which == 27 ) {
  43. $('#contactForm').fadeOut();
  44. $('#content').fadeTo( 'slow', 1 );
  45. }
  46. } );
  47.  
  48. }
  49.  
  50. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement