Udoro

useful ON-CLICK codes

Feb 28th, 2021 (edited)
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. TRIGGER ANOTHER OBJECT ON CLICK
  2.  
  3. jQuery('.trigger').on('click', function(){
  4.  
  5. jQuery('.target').click();
  6.  
  7. });
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14. SHOW OR HIDE ANOTHER OBJECT ON CLICK
  15.  
  16.  
  17.  
  18.  
  19. jQuery(document).ready(function(){
  20.  
  21.  
  22.  
  23. jQuery("#link_button-212-2").click(function(){
  24. jQuery("#section-136-2").show();
  25.  
  26.  
  27. // lock scroll position, but retain settings for later
  28. /*
  29. var scrollPosition = [
  30. self.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft,
  31. self.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop
  32. ];
  33. var html = jQuery('html'); // it would make more sense to apply this to body, but IE7 won't have that
  34. html.data('scroll-position', scrollPosition);
  35. html.data('previous-overflow', html.css('overflow'));
  36. html.css('overflow', 'hidden');
  37. window.scrollTo(scrollPosition[0], scrollPosition[1]);
  38.  
  39. */
  40.  
  41. });
  42.  
  43.  
  44. jQuery("#link_button-225-2").click(function(){
  45. jQuery("#section-136-2").hide();
  46.  
  47.  
  48. // un-lock scroll position
  49. /*var html = jQuery('html');
  50. var scrollPosition = html.data('scroll-position');
  51. html.css('overflow', html.data('previous-overflow'));
  52. window.scrollTo(scrollPosition[0], scrollPosition[1])
  53. */
  54.  
  55.  
  56.  
  57. });
  58.  
  59. });
  60.  
  61.  
  62.  
  63.  
Add Comment
Please, Sign In to add comment