I'm trying to change the value of a variable when a button is clicked and pass the new variable to another function using jQuery, but it isn't working.
What am I doing wrong?
jQuery(document).ready(function($){
var day;
$('button#visual-live-time').on('click',function(){
var day = $('#datetimepicker').val();
});
$('div.countdown').countdown(day, function(event){
$(this).text(event.strftime('%D ημέρες %H ώρες %M λεπτά %S δευτερόλεπτα'));
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="col-lg-6">
<div class="panel panel-default">
<div class="panel-heading">Ημερομηνία και ώρα έναρξης</div>
<div class="panel-body">
<input type="text" size="35" name="event-title" id="datetimepicker">
</div>
</div>
</div>
<button type="text" id="visual-live-time"></div>
<div class="countdown"></div>