如下:
HTML(Pug)
input(type=“text” oninput=“inputHandler(this.value)”)
// this會指向Input元素
Javascript
function inputHandler(newVal){
console.log(newVal);
// or some other things you want to do with the value
}
※ 適用於onChange, onInput等監聽會被直接裝在要取值的元素上的事件監聽
Written on August 22nd , 2017 by Yumi Chen