<h1>My First JavaScript</h1>
<p>JavaScript can change the content of an HTML element:</p>
<button type="button" onclick="myFunction01()">Click Me!</button>
<p id="demo02">This is a demonstration.</p>
<script>
function myFunction01() {
document.getElementById("demo02").innerHTML = "Hello JavaScript!";
}
</script>
Result:
My First JavaScript
JavaScript can change the content of an HTML element:
This is a demonstration.
Example 02
HTML Code:
<h1>My First JavaScript</h1>
<p id="demo03">JavaScript can change the style of an HTML element.</p>
<script>
function myFunction02() {
document.getElementById("demo03").style.fontSize = "25px";
document.getElementById("demo03").style.color = "red";
document.getElementById("demo03").style.backgroundColor = "yellow";
}
</script>
<button type="button" onclick="myFunction02()">Click Me!</button>
Result:
My First JavaScript
JavaScript can change the style of an HTML element.
<noscript> Tag
The <noscript> tag is used to provide an alternate content for users that have disabled scripts in their browser or have a browser that doesn't support client-side scripts.
HTML Code:
<p id="demo04"></p>
<script>
document.getElementById("demo04").innerHTML = "Hello JavaScript!";
</script>
<noscript>Sorry, your browser does not support JavaScript!</noscript>
<p>A browser without support for JavaScript will show the text written inside the noscript element.</p>
Result:
A browser without support for JavaScript will show the text written inside the noscript element.