js给input添加函数

Posted 流世幻羽

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了js给input添加函数相关的知识,希望对你有一定的参考价值。

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
	</head>
	
	<script>
		function heh(){
			var sid=document.getElementById("btn");
    		sid.onblur = Function("queryOccupationEveryType(this.value);");
		}
		function queryOccupationEveryType(){
			console.log("aa");
		}
		
		
	</script>
	
	<body>
		
		<input id="btn" >
		<input id="btn1" onclick="heh()" type="button" value="点我">
		
	</body>
</html>

  

以上是关于js给input添加函数的主要内容,如果未能解决你的问题,请参考以下文章