jQuery get input value not working on first page

Saturday, July 5, 2014

Hi I'm trying to get input value using jQuery, but it's not working on first instance when the button is pressed. It only works when I press back button to get back to this page:



<input type="text" class="form-control email_input" name='email' id="reserve_email_1" placeholder="Enter your email">
<button type="submit" id="subscribe_1" class="btn btn-success subscribe_button">Get now</button>


var email_1 = $('#reserve_email_1').text();


When I type something into the input and press the button, the alert shows an empty message, it then redirects to another page (it redirects since it's part of a form), then I press the back button again to go back to this page where the same text is left in the input, and this time when I press the button the alert message shows up with the text I put in.

Super confused. What's going on?