jquery toggle button value

前端 未结 5 1124
自闭症患者
自闭症患者 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条回答
  •  一整个雨季
    2020-12-10 06:08

    try ( in jQuery < 1.9 )

    $("input[type='button']").toggle(
        function(){
            $(this).val("Pause");
        }, 
        function(){
            $(this).val("Play");
        }
    );
    

    DEMO

    Note: The toggle event was deprecated in 1.8 and removed in 1.9

提交回复
热议问题