jQuery toggle div and toggle text

jquery

Solution

working demo http://jsfiddle.net/eDNH5/10/

This will help you!

the issue was you were using the assignment operator instead of equality `==`

Jquery code

$(document).ready(function() {
    $("#addcmt").click(function() {
        $(".commentarea").toggle();
        if ($("#addcmt").text() == "Add additional comment") {
            $("#addcmt").text("Remove comment");
        }
        else {
            $("#addcmt").text("Add additional comment");
        }
    });
});​

Problem

I want to make the link "Add additional comment" when clicked to show a text area and the text to toggle as "Remove comment". When "Remove comment" is clicked it should hide text area and the text need to change as "Add additional comment". The code I used is ``` <script type="text/javascript"> $(document).ready(function( ){ $("#addcmt").click(function( ) { $(".commentarea").toggle( ); if ($("#addcmt").text = "Add additional comment") { $("#addcmt").text("Remove comment"); } else { $("#addcmt").text("Add additional comment"); } }); }); </script> ``` The html is ``` <div class="addlcomment"> <a id="addcmt">Add additional comment</a> </div> <div class="commentarea" style="display:none;"> <textarea name="strcomments1" tabindex="2"></textarea> </div> ``` The text toggle is not working. Any help is appreciated.

Original source