The problem is that I get on value from check box when it's checked and when it's unchecked... what do I miss?
HTML checkbox code :
<input type="checkbox" id="noextracharge" name="noextracharge" >
<label for="noextracharge">no extra charge</label><br>
to get the values from page's inputs I use :
function getInputValues() { //var enabledInputs array of inputs ids
var inputValues = {};
$.each(enabledInputs, function (index, inputId) {
var input = $(inputId);
inputValues[input.attr("name")] = input.val();
});
return inputValues;
};
It will always return the same. To get if the checkbox is checked or not use .is(":checked")
if you need to check the type before use prop("type") === "checkbox"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.