<input id="c-nums" class="form-control" onblur="abc()" name="row[nums]" type="number"...>
当表单失去焦点后触发abc函数,怎么才能在abc函数中获取到这个input的id和name?
<input id="c-nums" class="form-control" onblur="abc()" name="row[nums]" type="number"...>
当表单失去焦点后触发abc函数,怎么才能在abc函数中获取到这个input的id和name?
传 this 进到 function 两种方法onblur="abc.call(this)"
function abc(){
console.log(this.id, this.name)
}
onblur="abc(this)"
function abc(that){
console.log(that.id, that.name)
}
13 回答12.8k 阅读
7 回答2k 阅读
3 回答1.1k 阅读✓ 已解决
2 回答1.2k 阅读✓ 已解决
6 回答935 阅读✓ 已解决
6 回答1.1k 阅读
2 回答1.3k 阅读✓ 已解决