<head>
<script type="text/javascript">
function showHint(str){
alert(str)
}
</script>
</head>
<body>
<input type="text" onkeyup="showHint(this.value)"/> <!--此处,在html标签中的this代表的是此标签-->
</body>
</html>
this就是你当前要执行的js所抓获的节点,这样在js里就可以不用document.getElement之类的写法来抓获id,name或标签名,省去一些麻烦。一般用obj来代替。<input type="button" id="tianjia" value="保 存" class="btn1" onClick="nullCheck(this)"/>
<script>
function nullCheck(obj)
{
......//这里写你所需功能的代码
}
</script>