SHARE
TWEET

Untitled

a guest Jan 4th, 2013 18 Never
  1. <div>
  2.     <div>Other Div</div><button>Click Me</button>
  3. </div>
  4. <div>
  5.     <div>Other Div</div><button>Click Me</button>
  6. </div>
  7.        
  8. var buttons = document.body.getElementsByTagName('button');
  9. for(var x = 0; x < buttons.length; x++) {
  10.     buttons[x].onclick = function() {
  11.         this.previousSibling.style.backgroundColor = '#3a6d90';
  12.     }
  13. }
RAW Paste Data
Top