javascript - jquery change button text from save to edit 2 ways -


i newbie in programming , wanna ask how change button 2 way.

<button type="button" id="button">save</button> <script>  $(document).ready(function() {    $('#button').click(function(){      $('#button').text("edit");       });        }); 

initial when click turn "edit" how click "save" when clicking.

thank you

write small toggle function:

$('#button').on('click', function() {     $(this).text(function(_, value) {         return value == 'save' ? 'edit' : 'save';     }); }); 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -