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
Post a Comment