How to include inline JavaScript inside an HTML page?

JavascriptWeb DevelopmentFront End Scripts

JavaScript is used in HTML using the <script>…</script> or using External JavaScript file. Well, there’s another way through which you can include inline JavaScript inside an HTML page.

Generally, the HTML event attributes calls functions specified elsewhere in script tags. But, you can also add the JavaScript code directly to the onClick event tags.

Note: Adding inline JavaScript isn’t considered a good practice according to coding standards and shouldn’t be followed.

   <a href="#" onClick="alert('Hello World');">
Updated on 04-Oct-2019 12:12:32