Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div>
- <div>Other Div</div><button>Click Me</button>
- </div>
- <div>
- <div>Other Div</div><button>Click Me</button>
- </div>
- var buttons = document.body.getElementsByTagName('button');
- for(var x = 0; x < buttons.length; x++) {
- buttons[x].onclick = function() {
- this.previousSibling.style.backgroundColor = '#3a6d90';
- }
- }
-
Add Comment
Please, Sign In to add comment