日期:2014-05-16  浏览次数:20410 次

请教页面元素变动触发事件
web     html   页面   中内容改动   可以触发什么事件


我需要实现的效果是
我在页面中编辑,离开时如没有保存提示保存,如果页面变动可以触发某个事件,
获得一个标记就可以处理了

请教方法

------解决方案--------------------
jquery

$( "intpu ").click(function(){window.hasChanged=true; this.click();});
------解决方案--------------------
原来有人问过,高手答过,俺看过!

L@_@K

<body>
UserName: <input type= "text " name= " " value= "yixianggao "> <br />
Favorite: <input type= "text " name= " " value= "JavaScript "> <br />
Age: <input type= "text " name= " " value= " "> <br />
<input type= "button " name= " " id= "btnSumbit " value= "Go CSDN ">
</body>
<script language= "JavaScript ">
<!--
var btnSubmit = document.getElementById( "btnSumbit ");

btnSubmit.onclick = function() {
var colInput = document.getElementsByTagName( "input ");
for (var i=0; i <colInput.length; i++)
{
if (colInput[i].defaultValue != colInput[i].value)
{
if (confirm( "尚未保存,是否离开? ")) break;
else return;
}
}
window.location.href = "http://community.csdn.net/ ";
};
//-->
</script>