Do you want to be a good Web Developer?

Enter Your Email To Get Our Exclusive Tutorials
And Offer Right In Your Email

HTML Javascript

HTML Javascript


HTML Javascript is used to add interactivity on the webpage like alertbox or show hide the div or element.The script can be written using Javascript or VBScript.


Syntax:<script>Anything you define here</script>.script tag is always placed inside head tag.


  • External Javascript:Define script rules in a separate .js file and then include that file in your HTML document using HTML <script> tag.
  • Internal Javascript:Define script in the <head> tag inside <script> tag.


External Javascript

demo.js

function sample()
{
alert('This is the example of External Javascript');
}

scriptdemo.html

<! DOCTYPE html>
<html>
<head>
<srcipt src="demo.js" type="text/javascript"/></script>
</head>
<body>
<input type="button" onclick="sample();" value="Click">
</body>
</html>

Result of the above Example




Internal Javascript

<! DOCTYPE html>
<html>
<head>
<srcipt type="text/javascript">
function sample()
{
alert('This is the example of Internal Javascript');
}
</script>
</head>
<body>
<input type="button" onclick="sample();" value="Click">
</body>
</html>

Result of the above Example



You will learn complete Javascript in Javascript Tutorials


PreviousNext

Join Us With Our 21000+ Subscribers And Get Our Latest Tutorials Update Via Email