jQuery Toggle Text?

后端 未结 20 990
日久生厌
日久生厌 2020-12-02 05:52

How to toggle HTML text of an anchor tag using jQuery? I want an anchor that when clicked the text alternates between Show Background & Show Text

20条回答
  •  一个人的身影
    2020-12-02 06:28

    Perhaps I'm oversimplifying the problem, but this is what I use.

    $.fn.extend({
        toggleText: function(a, b) {
            $.trim(this.html()) == a ? this.html(b) : this.html(a);
        }
    });
    

提交回复
热议问题