我试图在输入字段中发生onfocus事件时调用函数,但是它给出了错误
函数未在htmlinputelement.onfocus中定义
HTML:
<input type="text" class="form-control" onFocus="forFocus(this);" id="name"
aria-describedby="emailHelp" placeholder="Enter Name">
Javscript函数:
function forFocus(element){
console.log('here on focus is called now', element);
}
答案 0 :(得分:-1)
<script>
function func1() {
console.log('func1');
}
</script>
<input type="text" id="foo" onfocus="func1()">
请参阅example