Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Test</title>
- <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
- </head>
- <body>
- <style type="text/css">
- .film-title {
- color: black;
- }
- .film-title.watched {
- color: red;
- }
- </style>
- <p class="film-title">Foo</p>
- <br/><br/>
- <div>
- <select>
- <option>First</option>
- <option>Second</option>
- <option>Third</option>
- </select>
- </div>
- <p class="film-title">Bar</p>
- <br/><br/>
- <div>
- <select>
- <option>First</option>
- <option>Second</option>
- <option>Third</option>
- </select>
- </div>
- <p class="film-title">Baz</p>
- <br/><br/>
- <div>
- <select>
- <option>First</option>
- <option>Second</option>
- <option>Third</option>
- </select>
- </div>
- <script type="text/javascript">
- (function ($) {
- $('select').change( function () {
- $(this).closest( 'div' ).prevAll( '.film-title' ).first().addClass( 'watched' );
- } );
- })( jQuery );
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement