Later, with the help of the great Baidu, I finally found the cause of the problem:
$("") is a jquery object, not a dom element
value is an attribute of dom element
jquery corresponds to val
val(): Get the first matching element current value.
val(val): Set the value of each matching element.
So, the code should be written like this:
Value: val = $("#id")[0].value;
Assignment:
$("#id")[0].value = "new value";
Or $("#id").val("new value");
Or this also works: val = $("#id").attr("value");
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn