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附加回调时我找不到回调?
要查看jQuery绑定使用的事件:
$("#helloworld").data('events');
Run Code Online (Sandbox Code Playgroud)
如果按照示例绑定焦点,并在firebug控制台中运行上面的操作,它将返回
Object focus=Object
Run Code Online (Sandbox Code Playgroud)