16
rated 0 times
[
18]
[
2]
/ answers: 1 / hits: 24161
/ 11 Years ago, tue, november 5, 2013, 12:00:00
I want to get values of all input fields with jQuery. I can do that with following code. However if the input field is checkbox, and it is checked, it will return on. How can I get the value as 1 if checked?
jQuery:
$('button').click(function() {
inputs = $('.input');
inputs.each(function() {
var value = $(this).val();
alert(value);
});
});
HTML:
<input type=text class=input />
<input type=text class=input />
<input type=checkbox class=input>
<button>Get values<button>
Demo:
http://jsfiddle.net/yDKdT/
More From » jquery