Advertisement
Guest User

Active parent

a guest
Nov 10th, 2012
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.76 KB | None | 0 0
  1. <html>
  2. <head>
  3. <style type='text/css'>
  4.  
  5. div:active {
  6.     background-color:orange;
  7. }
  8.  
  9. div:focus {
  10.     outline:none;
  11. }
  12.  
  13.  
  14. </style>
  15. <script type='text/javascript'>
  16. window.onload = function() {
  17.     var allSpans = document.getElementsByTagName('span');
  18.  
  19.     for(var x = 0; x < allSpans.length; x++) {
  20.         allSpans[x].parentNode.setAttribute('tabIndex',0); // this might not be required
  21.         allSpans[x].onclick = function() {
  22.             this.parentNode.focus();
  23.         }
  24.     }
  25. }
  26. </script>
  27. </head>
  28.  
  29. <body>
  30.  
  31.  
  32. <div style='width:100px; border: 1px solid black'>
  33.     <span>Line 1</span>
  34. </div>
  35.  
  36. <div style='width:100px; border: 1px solid black'>
  37.     <span>Line 2</span>
  38. </div>
  39. <div style='width:100px; border: 1px solid black'>
  40.     <span>Line 3</span>
  41. </div>
  42.  
  43. </body>
  44.  
  45. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement