我目前正在使用 FireBug 1.3.0 和 jQuery 1.2.6 在 Mozilla FireFox 3.0.5 中对此进行测试。
第一次尝试
document.getElementById("x").onfocus = function ()
{
var helloWorld = "Hello World";
};
FireBug 控制台:
document.getElementById("helloworld").onfocus.toString() = 函数体作为字符串
$("#helloworld").get(0).onfocus.toString() = 函数体作为字符串
第二次尝试
$("#helloworld").focus(function ()
{
var helloWorld = "Hello World";
});
FireBug 控制台:
document.getElementById("helloworld").onfocus.toString() = FireBug 什么都不返回
$("#helloworld").get(0).onfocus.toString() = FireBug 什么也不返回
我在这里想念什么?为什么在使用 jQuery 附加回调时找不到回调?