jquery toggle button value

前端 未结 5 1119
自闭症患者
自闭症患者 2020-12-10 05:44

In the below code when the play button is clicked Its value should be changed to pause and when pause is clicked the other function should be called .How to do this using jq

5条回答
  •  -上瘾入骨i
    2020-12-10 06:05

    A simplest idea can be this

    function play(action) {
     { 
       if(action=='play') { 
          play_int(); 
          $("#btn_play").val('pause');
       }
       else { 
          pause_int(); 
          $("#btn_play").val('play');
       }
    }
    
    $("#btn_play").click(function() {
       val = $(this).val();
       play(val);
    }
    

提交回复
热议问题