function x(){
alert(this)
}<input id="x" type="text" />document.getElementById("x").onclick=x如果用这个写法 在函数x中 可以用 this引用 这个input但是如果 onclick="x()" 这样写 那如何在 方法中引用 引用这个 input用 this的话 引用的是 window对象该如何做?
alert(this)
}<input id="x" type="text" />document.getElementById("x").onclick=x如果用这个写法 在函数x中 可以用 this引用 这个input但是如果 onclick="x()" 这样写 那如何在 方法中引用 引用这个 input用 this的话 引用的是 window对象该如何做?
解决方案 »
- 正则表达式Match方法
- 全角输入下delete,箭头键无效
- Using('System.Web.Forms.MzBehavior');如何激活该事件!
- 怎么提取iframe里的内容
- 小女子求助高手帮忙
- ----------怎样在用window.open()打开的新窗口中控制status bar中进度条的宽度?
- 如何使用javascript动态设置checkbox的checked属性?昨天一夜没睡,在线等,解决马上结贴!不胜感激!!!
- 帮我看看这个类似MSN消息提示相关的问题!!!
- 关于正则表达式的详细语法
- JScript中使用Math.max问题
- javascript中的^是什么运算符
- jquery刷新页面问题
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
function x(){
alert(this)
}
window.onload = function() {
document.getElementById("x").onclick=x
};
</script>
</head>
<body>
<input id="x" type="text" value="hit me" />
</body>
</html>
alert(document.activeElement);
}
alert(obj.value);
}