how to toggle anchor tag text in jquery [Resolved]

Posted by Ankitsrist under jQuery on 4/6/2013 | Points: 10 | Views : 6726 | Status : [Member] | Replies : 1
hello,
i want to toggle anchor tag text, i have an anchor tag within div, when user clicks on reply, comment box get open and text should change into close and vice versa but problem is that after text getting change to close, text remain become close nd toggle between show nd hide works clearly...

<a id="reply" href="#">reply</a>
<div id="replyuser" style=" position:absolute;"><asp:TextBox ID="txt1" CssClass="txtbox" TextMode="MultiLine" runat="server"></asp:TextBox><br /><asp:Button ID="btnreply" Text="send" runat="server" CssClass="btn" /></div>


jquery is as follows

 $(document).ready(function() {
$("#replyuser").hide();

$("#reply").click(function() {

$("#replyuser").toggle(function() {

$("#reply").text("close");
});

});
});





Responses

Posted by: Ankitsrist on: 4/6/2013 [Member] Starter | Points: 25

Up
0
Down

Resolved
here is the solution
    $(document).ready(function() {

$("#replyuser").hide();

$("#reply").click(function() {

$("#replyuser").toggle(function() {
$(this).is(":visible") ? $("#reply").text("close") : $("#reply").text("reply");
//$("#reply").text("close");
});

});
});


Ankitsrist, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response