18.11.13

JAVA SCRIPT BASICS


Hello everyone ... 

today lets take a look on Java Script basics. so buddies please don't be impatient, this series will improve gradually... & hope will benefit both groups of Non programmer or Just programmer of any hard core language.

So let's have a look on these two statements.

1) document.getElementById("id_name").innerHTML="My first HTML text";

2) var x = document.getElementById("id_name");
x.innerHTML = "My Second HTML text";

Lets see some explanation regarding these two statements.

The first one says "Put the the text ("... ") on the right hand of assignment or equals to sign in the HTML of id_name.
now, see , how it works... it says , that is, Browser looks over it in following manner- Get me the HTML property of Element specified by the ID namely "id_name" in the respective document. 

Due to the above JavaScript statement we see a change on the specific id of any tag in the available document.

So that was the story of how we would put our own hand written HTML or just TEXT or it also may possible some output stored in some variable.

Now... look over 2nd statement-  what it says- Two points..

i) Store the ID retrieved using the specific Element of available document.
ii) Similar to the first statement but with a little twist which is as -"put this user one HTML /TEXT in the HTML property of ID stored in the variable 'x'

These are the first two Lessons for today, which you may use in styling your HTML text dynamically in JavaScript. If you are still unable to grasp these two statement kindly write in the comment box. & I ll represent a more graspable example as soon as possible.

Thanks!!!

No comments:

Post a Comment

Search This Blog

Let make your friend aware about this post