How To Get Value Of Input Tag In Javasctipt
This input tag always gives null value, what is problem with this code Input tag (HTML)::
P.S. I assume you want the input inside the form.
P.S. I assume you want the input inside the form.
I assume you want to get the value entered in the form on submitting.
You can add a name attribute to yourinput tag like so:<input name="title" id="my_input"> then in the javascript file you can write this:
$('form').submit(function(e)){
e.preventDefault();
let formdata = $(this).serialze();
console.log(formdata.title);
}
Wrap the input with the form tag...your inputs must be between the form tag.
The line let formdata = $(this).serialze(); takes the values with the name atttribute and stores it in the variable formdata
Post a Comment for "How To Get Value Of Input Tag In Javasctipt"