<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)
}
10 回答11.1k 阅读
6 回答3k 阅读
5 回答4.8k 阅读✓ 已解决
4 回答3.1k 阅读✓ 已解决
2 回答2.7k 阅读✓ 已解决
3 回答2.3k 阅读✓ 已解决
3 回答2.1k 阅读✓ 已解决