Change button text (show / hide/ show) on click in jquery toggle

前端 未结 3 1180
情书的邮戳
情书的邮戳 2021-02-10 06:27

I am working on this fiddle: http://jsfiddle.net/cED6c/7/ I want to make the button text change on click and I tried using the following code:



        
3条回答
  •  情深已故
    2021-02-10 07:07

    Very easy to change the text using jQuery.

    Working example here. http://jsfiddle.net/vp7Y7/

    $('.reveal').click(function() {
        if ($(this).text() === 'Show Answer') {
             $(this).text('This is NEW TEXT!!! It Worked!');
        }
        else {
            $(this).text('Show Answer');
        }
    });
    

提交回复
热议问题