HTML uses the javascript for logical functions to make the output logic
JavaScript uses two types of functions they are
The <script>
tag is used to define a client-side script, such as a JavaScript.
The <script>
element either contains scripting statements or it points to an external script file through the src attribute.
Common uses for JavaScript are image manipulation, form validation, and dynamic changes of content.
<p id="function
"></p>
<script>
document.getElementById("function").innerHTML = "Welcome To JavaScript!";
</script>
In the above code snippet we have defined the Usage of Javascript in HTML, The given <p>
tag with id as function and script tag with predefined function as document.getElementByID
as function with the value as Welcome to javascript, we have given the id function to the <p>
tag to call the function of the javascript
output
We can use the javascript functions to the HTML buttons
<h1>HTML Javascript</h1> <p>Click on the button to open the Text</p> <button type="button" onclick="myJava()">Click Me!</button> <p id="demo"></p> <script> function myJava() { document.getElementById("demo").innerHTML = "Welcome To JavaScript!"; } </script>
output
We can the style of the html elements using javascript
<h1>TechFunda</h1> <p id="demo">It changes the fontsize of the text.</p> <script> function mystyle() { document.getElementById("demo").style.fontSize = "25px"; } </script> <button type="button" onclick="mystyle()">Click Me!</button>
id
as demo
and style.fontsize
is used to change the fontsize of the textoutput