Changing style of an element via vanilla Javascript
css, javascript, jquery
Solution
var elements = document.getElementsByTagName('a'),
l = elements.length;
while ( l-- ) elements[l].style.left = '0px';
Here's the fiddle: http://jsfiddle.net/236pk/
If you're using a modern browser, you can use this one liner:
document.querySelectorAll('a').forEach(e => e.style.left = '0px');
Here's the fiddle: http://jsfiddle.net/236pk/24
Problem
``` <a href="" style="right:0px">right</a> ``` I would like to change it into ``` <a href="" style="left:0px">right</a> ``` In jQuery I can do this ``` $('a').attr('style','left:0px'); ``` But how can I do this in traditional javascript without using jquery?