Advertisement
orksnork

Untitled

Apr 29th, 2015
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 2.92 KB | None | 0 0
  1. <div id='reasons_quiz'>
  2.   <div class='reasons_quiz_form'>
  3.     <p class='reasons_quiz_title'>What's Your Reason</p>
  4.    <div class="clearfix reasons_quiz_wrapper">
  5.      <div class='reason_options watch_options'>
  6.        <span>Do You Watch</span>
  7.        <p><a href="#" id="comedy" class="watch">Comedy</a></p>
  8.        <p><a href="#" id="action" class="watch">Action</a></p>
  9.    </div>
  10.    <div class='reason_options listen_options'>
  11.       <span>Do You Listen To</span>
  12.      <p><a href="#" id="rock" class="listen">Rock</a></p>
  13.      <p><a href="#" id="rap" class="listen">Rap</a></p>
  14.    </div>
  15.  </div><!-- end clearfix -->
  16.  <br />
  17.  <a href="#" id="reason-form-submit">GET YOUR CUSTOM REASON</a>
  18.  </div> <!-- reasons_quiz_form -->
  19.  
  20.    <div class="hide" id="reason-success">
  21.      <div id="success-content"></div>
  22.       <div id="twitter-area"><a href="http://twitter.com/intent/tweet?&text=%23ReasonsNotToSmoke" class="reasons_quiz_twitter_sharing" target="_blank">Tweet Your Reason</a></div>
  23.   </div><!-- end reason-success-->
  24.  
  25. </div> <!-- reasons_quiz -->
  26.  
  27.  
  28. <script>
  29.  
  30. function formWatch() {
  31.         //actions for watch selection
  32.         $('.watch_options a').on('click', function(e) {
  33.             var $this = $(this);
  34.             $('.watch_options a.selected').removeClass('selected')
  35.             $this.addClass('selected');
  36.             e.preventDefault();
  37.         });
  38.         //actions for listen selection
  39.         $('.listen_options a').on('click', function(e) {
  40.             var $this = $(this);
  41.             $('.listen_options a.selected').removeClass('selected')
  42.             $this.addClass('selected');
  43.             e.preventDefault();
  44.         });
  45.         //actions for form submit
  46.         $('#reason-form-submit').on('click', function(e) {
  47.             $('.reasons_quiz_form').fadeOut();
  48.             $('#reason-success').fadeIn();
  49.             if ($('.watch_options a').hasClass('selected') && $('.listen_options a').hasClass('selected')) {
  50.                 if ($('.reasons_quiz_form #comedy').hasClass('selected') && $('.reasons_quiz_form #rock').hasClass('selected')) {
  51.                     $('#success-content').html('I don&rsquo;t smoke because gum disease isn&rsquo;t part of my game plan.');
  52.                 } else if ($('.reasons_quiz_form #comedy').hasClass('selected') && $('.reasons_quiz_form #rap').hasClass('selected')) {
  53.                     $('#success-content').html('I don&rsquo;t smoke because I can&rsquo;t freestyle with a cough');
  54.                 } else if ($('.reasons_quiz_form #action').hasClass('selected') && $('.reasons_quiz_form #rock').hasClass('selected')) {
  55.                     $('#success-content').html('I don&rsquo;t smoke because rebels need full-sized lungs');
  56.                 } else if ($('.reasons_quiz_form #action').hasClass('selected') && $('.reasons_quiz_form #rap').hasClass('selected')) {
  57.                     $('#success-content').html('I don&rsquo;t smoke because yellow teeth would kill my game');
  58.                 }
  59.             } else {
  60.                 $('#success-content').html('I don&rsquo;t smoke because I want to live on the edge, not on the sidelines.');
  61.             }
  62.             e.preventDefault();
  63.         });
  64.     }
  65. $(document).ready(function() {
  66.             formWatch();
  67.         });</script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement