Advertisement
Guest User

AskMe 223780

a guest
Sep 4th, 2012
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 1.08 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.     <head>
  4.         <title>Test</title>
  5.         <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
  6.     </head>
  7.     <body>
  8.         <style type="text/css">
  9.             .film-title {
  10.                 color: black;
  11.             }
  12.  
  13.             .film-title.watched {
  14.                 color: red;
  15.             }
  16.         </style>
  17.  
  18.         <p class="film-title">Foo</p>
  19.         <br/><br/>
  20.         <div>
  21.             <select>
  22.                 <option>First</option>
  23.                 <option>Second</option>
  24.                 <option>Third</option>
  25.             </select>
  26.         </div>
  27.  
  28.         <p class="film-title">Bar</p>
  29.         <br/><br/>
  30.         <div>
  31.             <select>
  32.                 <option>First</option>
  33.                 <option>Second</option>
  34.                 <option>Third</option>
  35.             </select>
  36.         </div>
  37.  
  38.         <p class="film-title">Baz</p>
  39.         <br/><br/>
  40.         <div>
  41.             <select>
  42.                 <option>First</option>
  43.                 <option>Second</option>
  44.                 <option>Third</option>
  45.             </select>
  46.         </div>
  47.  
  48.         <script type="text/javascript">
  49.             (function ($) {
  50.              $('select').change( function () {
  51.                 $(this).closest( 'div' ).prevAll( '.film-title' ).first().addClass( 'watched' );
  52.                 } );
  53.             })( jQuery );
  54.         </script>
  55.     </body>
  56. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement