I wanted to make an input value same to above input val using jquery.The above input type val is coming from a function. But don't know why the second input value is being set to undeefined and console gives no error.
HTML :
<input type="hidden" name="date" id="transactiona_date">
I Tried jquery 1.
console.log($("#myDate").val());
$("#transactiona_date").val($("#myDate").val());
console.log($("#transactiona_date").val());
2.
console.log($("#myDate").val());
$('#transactiona_date').val($("#myDate").val());
console.log($("#transactiona_date").val());
I even tried changing id to class in jquery as well as in html
console.log($("#myDate").val());
$(".transactiona_date").val($("#myDate").val());
console.log($(".transactiona_date").val());
No matter what i do i always get this in console.
06-02-2018
undefined
Any help why it is behaving like this ?
Also the myDate is getting value from
<input style="width:98%;margin-left:1%;margin:right:1%" type="text" name="invoice_date" id="myDate" value="<?php echo date('d-m-Y'); ?>">
Also i have no other error showing in console.And i want to share that the following id's or there is no other thing or code containing a relation to this code in same page , still lets consider a possibility of something interfering with the code, can you suggest a suitable way to diagnose my problem or how can i check what's been wrong in my code.