SUBSCRIBE OUR YOUTUBE CHANNEL 👉
Join in Google News
If You Want Adsense Approval for your blog Contact Us Adsense Ready theme Now!

JavaScript Programming-Calling JavaScript






Hi Web Developers! back again with the tech teacher. this time we will discuss how to call JavaScript either in the <head> tag or in the <body> tag. let's start the material, in the past material we have discussed how to insert JavaScript or embedded in HTML elements like this:


If the insertion is like the one above, the text of this JavaScript will automatically appear as "This text comes from embedded JavaScript". Unlike the case if we insert it in the <head> tag as follows:





But unfortunately the browser still executes JavaScript so the browser will display the same output as it inserted in the tag <body>.

Maybe you can understand this explanation, therefore we will proceed to the next material as the title above Calling Javascript so with the help of this friendly HTML and JavaScript we can hide and show an element, at this situation we will call JavaScript because if it is not called it will hide the element, here's what it looks like:




You can just put the JavaScript and the caller in the <body> tag as follows:


The important thing is that the caller's position must be below the JavaScript that will be called, don't get it upside down, it's obvious that the result is an error or doesn't appear, because the nature of the browser will execute the lines of code from top to bottom.

For the demo, please copy the code above then paste it in the HTML Editor>HTML tab. To see the results, select the output tab. 

Thank you. Hope it's useful.

Post a Comment