Comment using HTML and Javascript -


i have task create comment box in html , javascript how delete comment using button delete? or should use linked list in task? code:

<html>     <body>         <div id='container'>             <textarea id='txt'></textarea><br/>             <button type='button' onclick="add()">enter</button>             <div id='contents'></div>         </div>          <script>             function add(){                 var txt= document.getelementbyid('txt').value;                 var content= document.getelementbyid('contents');                 var tes= '<hr/><span>'+txt+"</span><button type='button'>delete</button>";                 content.innerhtml+=tes;             }         </script>     </body> </html> 

to answer question quick, if wanna stick pure javascript, can remove element dom using parent, take @ remove element id

p.s don't need way store comments somewhere (database?)

p.s.2 should avoid using html tags directly in string assigned variable. maybe should take @ best practice on web (regarding dom manipulation, jquery clone() method etc)

hope helps


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -