I am new to jquery. I was trying to toggle the input field when a button is clicked. I also changed the value on the button. Now when I click the input field hides and value of button changes. I want the value to restore back when the button is clicked twice.
Does that makes sense?
Here is the code:
$(document).ready(function() {
$('#submit').click(function() {
$('#hello').toggle();
$('#submit').val("I don't love you");
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input id="hello" type="text">
<input type="text">
<input type="text">
<input id="submit" type="button" value="love you"></button>