-4

I have written this html:

 <a href="#" class="addcomment">Add Comment</a>
<div id="addcomment">
<form name="comment" action="" method="post">
<input type="text" name="addcomment" size="80" />
<input type="submit" value="Comment">
</form>  

What I want is when I click the "Add comment" then form should be displayed in place of "Add comment" just like on "stackoverflow". How can I make this happen??

Stephen
  • 17,981
  • 4
  • 30
  • 31
gamer
  • 5,293
  • 12
  • 52
  • 86

2 Answers2

0

Here's a quick and dirty proof, optimize from here:

CSS:

#addcomment {
    display : none;
}
.addcomment:active {
    display : none;
}
.addcomment:active + #addcomment {
    display : block;
    position : absolute;
    top : 5px;
}

http://jsfiddle.net/7uax74qd/

AlienWebguy
  • 75,484
  • 17
  • 116
  • 141
  • I tried this and it worked but when I click add comment it appears and when I release it disappear.. whats the problem?? – gamer Nov 28 '14 at 09:23
0

Use javascript for it...

 <a href="#" id="add" class="addcomment" onclick="show()">Add Comment</a>
<div id="addcomment" style="display:none;">
<form name="comment" action="" method="post">
<input type="text" name="addcomment" size="80" />
<input type="submit" value="Comment">
</form>

THEN IN JAVASCRIPT write a function and call that in anchor tag..

function show()
{
document.getElementById('add').style.display='none';
document.getElementByid('addcomment').style.display='block';
}