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

rdbms - what exactly the undo information lives in oracle? -

bash - How do you programmatically add a bats test? -

java - Getting exception in JDBC thin driver -