How can i achieve this using jQuery. I have two text inputs on the page, so when the users has entered text and left the input field, for that text to be inserted into the DOM so i can access it?
EDIT:
To clarify i have this:
Expected Delivery Date: <input id="exp" type="text">&l开发者_运维知识库t;/input>
What i'm trying to do is print the contents of the page, but its not printing this input value?
This is the only input i need from the user so i wanted to avoid having to submit the form just for one input!
Your inputs are already in the DOM, you can get their value using .val()
like this:
var myValue = $("#inputID").val();
You may need to use a different selector but the idea stays the same, it's $(selector).val()
, or possible this
, for example if you want the value when the user leaves:
$("input").blur(function() {
alert($(this).val());
});
You can test it here.
Something like this?
$('.my-input-fields').blur(function() {
var div = $('<div/>');
div.html( $(this).val() );
$('#DOMplaceOfEntry').append(div);
});
精彩评论