![](/img/trans.png)
[英]Javascript onchange(this.value, that.value) not working on ipad
[英]Javascript this.value onchange not working
我正在嘗試獲取表單輸入 usign JS 的值:
HTML:
<td onchange="validate_hours(this)">{{ form.monday }}</td>
記者:
function validate_hours(elem) {
console.log(elem.value)
}
但我收到“未定義”。
{{ form.monday }} 是一個 Django 表格
Django表格:
<input type="number" name="form-0-monday" value="4.0" step="any" placeholder="0.0" id="id_form-0-monday">
我找到了解決方案,我使用 firstChild 獲取輸入,現在返回值:
JS
function validate_hours(elem) {
input = elem.firstChild.value
console.log(input)
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.