函数未在htmlinputelement.onfocus中定义

时间:2017-09-09 07:04:52

标签: javascript html

我试图在输入字段中发生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); } image of error which occure


请帮助链接http://jsfiddle.net/7gxnr7cb/18/

1 个答案:

答案 0 :(得分:-1)

<script>
function func1() {
    console.log('func1');    
}
</script>

<input type="text" id="foo" onfocus="func1()">

请参阅example