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

前端 未结 3 1182
情书的邮戳
情书的邮戳 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:17

    something easy like this

     $(document).ready(function () {
        $('a.edit').click(function () {
            var txt = $(this).text();
            txt = (txt !='cancel') ? 'cancel' : 'edit';
            $(this).text(txt);
            $('.editForm').toggle(300);
         });
    });
    

提交回复
热议问题