-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
  • 18,597
  • 4
  • 32
  • 33
gamer
  • 5,673
  • 13
  • 58
  • 91

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
  • 76,997
  • 17
  • 122
  • 145
  • 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';
}