I am trying to achieve a loading effect on the page load by CSS3 width transition. Here is the demo.
HTML
By removing the class from the span and setting it in JavaScript the browser will apply the transition, but this only works on the first .skill-bar
. Also .getElementsByClassName will not work in IE8 or below.
HTML
JavaScript
document.getElementsByClassName('skill-bar')[0].getElementsByTagName('span')[0].className = 'w70';
(so just wrap this in element after the HTML or see run function when page is loaded
Pure JavaScript demo
You probably want a jQuery (or other framework) solution to ensure cross-browser compatibility but that introduces a dependency on the framework. If you include jQuery already then great. If not you will need to include that library first and then use:
jQuery
$(window).load(function(){
$('.skill-bar span').addClass('w70');
});
jQuery demo
Right click on the output frame and select View frame source to see the output code.