Search This Blog

Friday, 29 July 2016

How pick the extract characters from the string using javascript?

Html page:

<button onclick="myFunction()">Try it</button>
<p id="P6"></p>

Javascript page:

<script>
    function myFunction() {
        var str = "Hello world!";
        var res = str.substring(1, 4);
        document.getElementById("demo").innerHTML = res;
    }
</script>

Output:

ell

No comments:

Post a Comment