Saturday, 6 August 2022

Change content of paragraph as current date on button click event

 


<!DOCTYPE html>
    <html lang="en">
    <body>
        <p id="p1"></p>
        <button id="btn">Click Me</button>
    <script>
    //change content of paragraph as current date on click event
    document.getElementById('btn').addEventListener('click',onclick);
    function onclick(e){
    const d=new Date();
    document.getElementById('p1').innerHTML=d;
    }
    </script>
    </body>
    </html>





No comments:

Post a Comment

Regular Expressions In JS

 index.html file <! DOCTYPE html > < html lang = "en" > < body > < script > let re ; re = /hello/ i ;  ...