function auditUpdate(newval) {
jQuery("#audit").val() = newval;
jQuery("#auditForm").submit();
}
Why do I get an error where I try to assign newval to the #audit
value?
In jQuery you assign a new value with:
jQuery("#audit").val(newval);
val()
without a variable works as a getter, not a setter.
jQuery doesn't complain about it. But your JavaScript interpreter does. The line
jQuery("#audit").val() = newval;
is invalid JavaScript syntax. You can't assign a value to the result of a function call. Your code says "call val
, get the return value -- and then assign newval
to the return value." This makes no sense.
Instead:
function auditUpdate(newval) {
jQuery("#audit").val(newval);
jQuery("#auditForm").submit();
}
the right syntax would be:
jQuery("#audit").val(newval);
val is a function, that, when executed, can't be assigned a value like you try to do.
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.