在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ 為什么總是獲取不到這兩個input的值?

為什么總是獲取不到這兩個input的值?

網點參數: <textarea id="dotinput" style="width:200px;height:200px;"></textarea>
<br/>
油墨擴大率: <input type="text" id="spreadrateinput" />
擴散精度: <input type="text" id="spreaddegreeinput" />
<input type="button" value="提交" onclick="fun()" />
        
        
var inkmax = document.getElementById('spreadrateinput');
var times = document.getElementById('spreaddegreeinput');
console.log(inkmax.value);
console.log(times.value);
回答
編輯回答
尤禮

<input type="text" id="spreadrateinput" onChange="changeFunction()" />
<input type="text" id="spreaddegreeinput" onChange="changeFunction()" />
changeFunction() {
var inkmax = document.getElementById('spreadrateinput');
var times = document.getElementById('spreaddegreeinput');
console.log(inkmax.value);
console.log(times.value);
}

這樣如何?

2018年1月15日 09:51
編輯回答
魚梓

:javascript是觸發(fā)機制的,不是你輸入數據就會執(zhí)行consloe語句;
:可以用onblur當input失去焦點的時候觸發(fā)事件;
:如果是提交到后臺,要用form表單的形式提交,盡量不要用getvalue的方式,安全性差;

2017年11月21日 22:21