在DOM元素上查找使用jQuery添加的回调函数

cll*_*pse 2 javascript jquery events callback

我目前正在使用带有jQuery 1.2.6的FireBug 1.3.0在Mozilla FireFox 3.0.5中进行测试.

第一次尝试

document.getElementById("x").onfocus = function ()
{
    var helloWorld = "Hello World";
};
Run Code Online (Sandbox Code Playgroud)

FireBug控制台:

document.getElementById("helloworld").onfocus.toString()=函数体作为字符串

$("#helloworld").get(0).onfocus.toString()=函数体作为字符串


第二次尝试

$("#helloworld").focus(function ()
{
    var helloWorld = "Hello World";
});
Run Code Online (Sandbox Code Playgroud)

FireBug控制台:

document.getElementById("helloworld").onfocus.toString()= FireBug什么都不返回

$("#helloworld").get(0).onfocus.toString()= FireBug什么都不返回


我在这里错过了什么?为什么在用jQuery附加回调时我找不到回调?

red*_*are 6

要查看jQuery绑定使用的事件:

$("#helloworld").data('events');
Run Code Online (Sandbox Code Playgroud)

如果按照示例绑定焦点,并在firebug控制台中运行上面的操作,它将返回

Object focus=Object
Run Code Online (Sandbox Code Playgroud)