Java Script tutorial 16
Today i am going to show you how to handle and access the attributes of controls using
var pElement = document.getElementById("paragraph1");
<p id="paragraph1">This is some text.</p>
<button onclick="change()" >Press and see</button>
Here in above code we made a paragraph which id is paragraph1 and a button whose onclick
use setAttribute for set the align to center. Then we access the current attribute by getAttribute and
show this is in alert. Now we remove that attribute(align) by removeAttribute.
By this the the paragraph's align first get change to center and then again goes to left because
of removing that attribute and by default the align attribute is left.