jQuery Toggle Text?

后端 未结 20 965
日久生厌
日久生厌 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:19

    Why don't you just stack them ::

    $("#clickedItem").click(function(){
      $("#animatedItem").animate( // );
    }).toggle( // <--- you just stack the toggle function here ...
    function(){
      $(this).text( // );
    },
    function(){
      $(this).text( // );
    });
    

提交回复
热议问题