Guest User

Untitled

a guest
May 23rd, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. $(document).ready(function(){
  2. var globalParent=null;
  3. var mouse_is_inside=false;
  4.  
  5. /*The snippet below is activated when an inputfield is focused*/
  6. $('.inputfield').focus(function(){
  7. globalParent=$(this).parent('div');
  8. globalParent.click();
  9. });
  10.  
  11. /*This following part will be activated when the inputfield loses focus*/
  12. $('.inputfield').blur(function(){
  13. globalParent.click();
  14. });
  15.  
  16. /*Following part will be activated when the user clicks anywhere inside
  17. the container div of the inputfield*/
  18. $('.field').click(function(){
  19. if(!($(this).is('.dummy'))){
  20. $('.dummy').css('background-color','gray');
  21. $('.dummy label').css('color','white');
  22. $('.dummy').removeClass('dummy');
  23. $(this).css('background-color','black');
  24. $(this).children('label').css('color','#3cdfdf');
  25. $(this).addClass('dummy');
  26. }
  27. });
  28.  
  29. /*The following code checks time and again whether the mouse is inside the form or not*/
  30. $('form').hover(function(){
  31. mouse_is_inside=true;
  32. },
  33. function(){
  34. mouse_is_inside=false;
  35. }
  36. );
  37.  
  38. /*If user clicks anywhere outside the form, all highlighting is removed*/
  39. $('body').click(function(){
  40. if(!mouse_is_inside)
  41. {
  42. $('.field').css('background-color','gray');
  43. $('.field label').css('color','white');
  44. $('.dummy').removeClass('dummy');
  45. }
  46. });
  47. });
Add Comment
Please, Sign In to add comment