Advertisement
AnimeSrbija

Jquery change select option next previous buttons AND Load c

Sep 20th, 2014
464
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.21 KB | None | 0 0
  1.  
  2. <!DOCTYPE html>
  3. <html>
  4. <head>
  5.   <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js'></script>
  6.  
  7.   <style type='text/css'>
  8.   .block{
  9.   background: #333333;
  10.   color: #fcfcfc;
  11.   width: 800px;
  12.   padding: 5px;
  13.   margin:5px 0px 0px 0px;
  14.   border: 2px #fff;
  15.   }
  16.   </style>
  17.  
  18. <script type='text/javascript'>//<![CDATA[
  19. $(window).load(function(){
  20. $(document).ready(function () {
  21.    $('.block').hide();
  22.    $('#option1').show();
  23.    $('#selectField').change(function () {
  24.        $('.block').hide();
  25.        $('#'+$(this).val()).fadeIn();
  26.    });
  27. });
  28. });//]]>  
  29.  
  30. </script>
  31. </head>
  32. <body>
  33. <center>
  34. <button type="button" id="prev">Previous</button>
  35. <select id="selectField" style="padding-left: 20px;width:150px">
  36.         <option value="option1">Lion</option>
  37.         <option value="option2">DOG </option>
  38.         <option value="option3">Cat</option>
  39.         <option value="option4">Lion</option>
  40.     </select>
  41. <button type="button" id="next">Next</button>
  42.  
  43.  <div id="option1" class="block"></div>
  44.  <div id="option2" class="block">DOG </div>
  45.  <div id="option3" class="block">Cat </div>
  46.  <div id="option4" class="block">Mouse</div>
  47.  
  48.  </center>
  49. </body>
  50. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement