Search This Blog

Sunday, 31 July 2016

How to display a string as superscript text using javascript?

Html page:

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

Javascript page:

<script>
    function myFunction() {
        var str = "Hello World!";
        var result = str.sup();
        document.getElementById("demo").innerHTML = result;
    }
</script>

output:

Hello World!

No comments:

Post a Comment