php - Show textarea or div (just below the comment to reply),when i click reply button on comment system javascript not jquery -
so trying make comment system in new site.all comments have reply button id 'replybtn' which, onclick want show textarea or input field inside div id 'replyform' right below respective comment. , using php,mysql retrieve comments.
<div class='cmt'> <div class='cmttext'></div> <div id='replybtn'></div> <div id='replyform'> <form method='post' ..... > <textarea name='reply' ></textarea> <input type='submit' /> </form> </div> </div>
thank you. first question asked on stackoverflow, sorry if have not given sufficient information.
try this. plain javascript. modify below want. :) updated it.
var varhtml = "<form method='post' ..... ><textarea name='reply' ></textarea> <input type='submit' /> </form>"; var allelements = document.body.getelementsbyclassname("replybtn"); var addcommentfield = function() { (var = 0; allelements.length > i; i++) { if (allelements[i] === this) { console.log("this " + i); if (document.getelementsbyclassname("replyform")[i].innerhtml.length === 0) { document.getelementsbyclassname("replyform")[i].innerhtml = varhtml; } } } }; (var = 0; < allelements.length; i++) { allelements[i].addeventlistener('click', addcommentfield, false); }
<div class='cmt'> <div class='cmttext'></div> <button class='replybtn'>replybtn</button> <div class='replyform'></div> </div> <div class='cmt'> <div class='cmttext'></div> <button class='replybtn'>replybtn</button> <div class='replyform'></div> </div> <div class='cmt'> <div class='cmttext'></div> <button class='replybtn'>replybtn</button> <div class='replyform'></div> </div>
Comments
Post a Comment