input type date, jQuery val() returns element tag and not value
date, html, input, jquery, variables
Solution
Some browsers use the id of elements as global variables, so since `npdl_dBirth` is the id of the input it will be set as a global variable referencing that variable. Try using a different variable name.
Also your variable is `ndpl_dBirth` but you try to print `npdl_dBirth`
Problem
I have a simple input tag: ``` <input type="date" class="basic_txt" name="date_birth" id="npdl_dBirth" value=""/> ``` And I need to assign the value of this input to a variable: ``` ndpl_dBirth = $('#npdl_dBirth').val(); ``` For some reason this is returning whole tag in a console when I try to print the variable out: ``` console.log(npdl_dBirth); ``` is returning this: ``` <input type="date" name="date_birth" id="r_date_birth" value> ``` I must be missing something really obvious, but can't find out what. Anyone any ideas? Thx in advance. Thank you for your help, just found my mistake, simply misspelled the variable. Thx anyway