Advertisement
Guest User

Div changes depending on a <select> menu

a guest
Sep 12th, 2012
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.07 KB | None | 0 0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="EN" lang="EN">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5.  
  6. <title>TEST</title>
  7. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js" type="text/javascript"></script>
  8. <script>
  9. $(document).ready(function () {
  10.     $('.group').hide();
  11.     $('#option1').show();
  12.     $('#selectMe').change(function () {
  13.         $('.group').hide();
  14.         $('#'+$(this).val()).show();
  15.     })
  16. });
  17. </script>
  18.  
  19. </head>
  20.  
  21.  
  22. <body>
  23.  
  24. <div id="option1" class="group">asdf</div>
  25. <div id="option2" class="group">kljh</div>
  26. <div id="option3" class="group">zxcv</div>
  27. <div id="option4" class="group">qwerty</div>
  28.     <select id="selectMe">
  29.         <option value="option1">option1</option>
  30.         <option value="option2">option2</option>
  31.         <option value="option3">option3</option>
  32.         <option value="option4">option4</option>
  33.     </select>
  34. </body>
  35. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement