Html page:
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
JavaScript page:
<script>
function myFunction() {
var str = "Hello World!";
var n = str.length;
document.getElementById("demo").innerHTML = n;
}
</script>
Output:
12
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
JavaScript page:
<script>
function myFunction() {
var str = "Hello World!";
var n = str.length;
document.getElementById("demo").innerHTML = n;
}
</script>
Output:
12
No comments:
Post a Comment