Jquery Toggle HTML

If you take a look at this page


I’m trying to get the <a> Tag to toggle between show and hide, and as you can see it works the first time using the $(this).html(‘Show’) command but I need it to toggle back to the original HTML when Show is clicked, (Change show to hide)


$('a.hideBox1').click(function() {


I don’t think you understand what I’m trying to do, I already have the box hiding, I’m trying to change the Text from ‘hide’ to ‘show’ and back again.

alright got it working looks like you can over write the Toggle Method like this

$(a).toggle(function() {
}, function() {

Not completely sure why it works but it works.

My example:

Toggles the hide/show text and as well toggles the box at the same time.

Glad you have it working though!

Oh ok, I see what you were doing now, that would work as well, thanks for the help

$(function() {
	var isClicked = false;
	$('a').click(function() {
		if (isClicked == false) {
			isClicked = true;
		else {
			isClicked = false;

would work as well… Kinda bulky though!

Just out of curiosity what if you wanted to change the HTML of the entire A tag.


change <a id=“whatever”>Text</a>
<a id=“newid”>Text</a>

Is that possible?

It is possible :slight_smile: You would have to change the attribute id… Remove the original one and add the new one…


Ok, makes sense, thanks for your help

<a id="new" href="#">Text</a>
$('a#new').click(function() {

Here is a gift you will soon learn to love :lol: