Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript jQuery function not returning

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #171763
    Chris Lowles
    Participant

    I’m currently stuck in a little pickle where I can’t get the HTML to return to its first value, as for that old loading script thread I started nevermind, I’m making one for my own anyway I’ve set up a pen here so people could check it out.

    Cheers!!

    #171773
    Paulie_D
    Member

    If all you are doing is swapping out the text…this might help

    https://css-tricks.com/swapping-out-text-five-different-ways/

    #171842
    Mawaha
    Participant

    Change your jQuery method to this

    $.fn.toggleHTML = function(attr1, attr2) {
            return this.each(function() {
              if ($(this).html() == attr1) $(this).html(attr2);
              else $(this).html(attr1);
            });
    };
    

    You were passing in the html() function as the first argument to the html() function in your else statement $(this).html($(this).html(), attr1)

    #171876
    Chris Lowles
    Participant

    Thanks for that.

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.