attachEvent问题 [英] attachEvent question

查看:80
本文介绍了attachEvent问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试让attachEvent为IE工作,但我遇到了问题。它第一次调用hello(),但脚本出错了。 hello()应该向attachEvent函数返回一些东西吗?我只是测试我可以从attachEvent调用一个函数。

展开 | 选择 | Wrap | 行号

解决方案

不要在第三个参数中运行该函数,只需引用它 -

传递 hello 而不是 hello()


非常好,就像一个魅力。我知道这是愚蠢的我做的!!


确定有效,但我想要做的是设置一个事件监听器,以便当用户点击表单时字段,如果它包含默认值,它应该清除它。

我不知道如何访问removeDef()函数中的值。我用这个吗?我需要检查



这就是我现在所拥有的。

展开 | 选择 | Wrap | 行号

I''m trying to get attachEvent to work for IE, but am having a problem. It calls hello() the first time, but then the script errors out. Should hello() be returning something to the attachEvent function? I''m just testing that I can call a function from the attachEvent.

Expand|Select|Wrap|Line Numbers

解决方案

do not run the function in the third argument, just reference it-
pass hello instead of hello()


Excellent, that worked like a charm. I knew it was something stupid I was doing it!!


Ok that worked, but what I''m trying to do is setup an event listener so that when a user clicks on a form field, if it contains the default value, it should clear it out.
I''m not sure how to access the value in the removeDef() function. Do I use this? I need to check


Here''s what I have now.

Expand|Select|Wrap|Line Numbers


这篇关于attachEvent问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆