Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.1 kB
1
Indexable
Never
<html>

<head>
    <script>
        function init(){
             var para = document.querySelector("p")
             //para.ondbclick = handler;
             /*para.ondbclick =(event)=>{
                 if(event.target.style.backgroundColor==" ")
                  event.target.style.backgroundColor = "red"
                  else  
                   event.target.style.backgroundCOlor =" "
             }*/
        }
        function  handler(event){
            if(event.target.style.backgroundColor==" ")
            event.target.style.backgroundColor = "yellow"
        else 
            event.target.style.backgroundColor = ""
           var newp = document.createElement("p")
           newp.innerHTML = event.target.innerHTML;
           event.target.parentNode.appendChild(newp)
        }
        </script>
        </head>
        <body onload="init()"
        <div>
             <form>
                 <input type ="text" id ="inp1">
                 <button onclick ="handler()">Click</button>
             </form>
             </div>

             </body>

    </html>