JS改变input的value值不触发onchange事件解决方案
2017-01-13 13:27
579 查看
$("#datetxt").on("input propertychange", function () {
alert('变化了');
});
http://blog.csdn.net/zhbitxhd/article/details/12943091
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta charset="utf-8" />
<title>My JSP 'testInput.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<script type="text/javascript">
function addValue(){
document.getElementById("mytext").value='dfdsafdsfsfsdfsdfdsf';
init();
}
function addValue2(){
document.getElementById("mytext").value='哈哈哈哈';
init();
}
function changeValue(){
document.getElementById("webtest").value=document.getElementById("mytext").value;
}
function init(){
if("\v"=="v"){//IE浏览器
document.getElementById("mytext").onpropertychange=changeValue;
}else{ // 其他浏览器
document.getElementById("mytext").addEventListener("input",changeValue(),false);
}
}
</script>
</head>
<body>
<input type="button" id="txts" value="点击加载值!" onclick="addValue();"/>
<input type="button" id="txts2" value="第二次改加载值!" onclick="addValue2();"/>
<input type="text" name="textfield" id="mytext"/>
<div>您输入的值为:<input id="webtest"></input></div>
</body>
</html>
alert('变化了');
});
http://blog.csdn.net/zhbitxhd/article/details/12943091
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta charset="utf-8" />
<title>My JSP 'testInput.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<script type="text/javascript">
function addValue(){
document.getElementById("mytext").value='dfdsafdsfsfsdfsdfdsf';
init();
}
function addValue2(){
document.getElementById("mytext").value='哈哈哈哈';
init();
}
function changeValue(){
document.getElementById("webtest").value=document.getElementById("mytext").value;
}
function init(){
if("\v"=="v"){//IE浏览器
document.getElementById("mytext").onpropertychange=changeValue;
}else{ // 其他浏览器
document.getElementById("mytext").addEventListener("input",changeValue(),false);
}
}
</script>
</head>
<body>
<input type="button" id="txts" value="点击加载值!" onclick="addValue();"/>
<input type="button" id="txts2" value="第二次改加载值!" onclick="addValue2();"/>
<input type="text" name="textfield" id="mytext"/>
<div>您输入的值为:<input id="webtest"></input></div>
</body>
</html>
相关文章推荐
- 1007. Maximum Subsequence Sum (25)
- Hexo-Theme-Buer主题修改介绍
- OpenGL ES: iOS 自定义 UIView 响应屏幕旋转
- rancher UI 使用
- C#request和response的中文乱码问题
- NGUI的事件通知架构和源码剖析
- request:fail ssl hand shake error 微信小程序(已解决!!) TLS1.2版本配置
- 【ife】任务四十一:UI组件之日历组件(二)
- iOS 复习笔记 UISlider基础篇(一)
- 绘制像素到屏幕上(Getting Pixels onto the Screen译文)
- 树梅派应用54:Adafruit的树莓派教程:使用控制电缆
- AVFoundation Programming Guide - Editing
- DataBindingGuidegoogle官方文档翻译(下)
- flask UEditor富文本提交数据到后台以及复现到前端页面
- MySQL添加映射连接到数据库时发生错误“FluentNHibernate.Cfg.FluentConfigurationException”
- 修复UEditor拖放大小的bug
- mybatis 插入数据报错:Incorrect string value: '\xE4\xBC\x9A\xE5\x91\x98' for column 'recipient' at row 1
- Quest 公司的Shareplex 与 GoldenGate比较
- break和continue的区别
- PyAutoGUI 简介【转】