How do you switch between two texts in one jQuery call?

前端 未结 4 1646
有刺的猬
有刺的猬 2021-01-20 08:28

Let\'s say you have a .click() call. What code could you write inside of that .click() call so that each time you click the selected element, you c

4条回答
  •  春和景丽
    2021-01-20 08:59

    Try this:

    $('#someElement').toggle(function(){
       $(this).text('text1');
      }, 
     function(){
       $(this).text('text2');
     }
    );
    

提交回复
热议问题