ITeye博客

解决IE7 IE8的input不触发onchange事件

conkeyn · 2018-10-22 10:49 · HTML · 互联网 · Markdown

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="js/jquery.min.js"></script>
</head>
<body>
<input type="text" id="input1" >
<div id="output" ></div>
<script type="text/javascript">
$('#input1').click(function () {
    // Cause the change() event
    // to be fired in IE8 et. al.
    this.blur();
    this.focus();
});
$('#input1').change(function() {
	change();
});
function change(){
	$("#output").html($("#input1").val());
}
</script>
</body>
</html>

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。