将处理程序绑定到IE中的事件

时间:2013-04-10 11:11:08

标签: javascript jquery internet-explorer binding

我正在尝试将一些函数绑定到一个事件。 以下代码在Chrome和FF中完全正常,但IE的相应代码是什么?

$this.mouseenter(function(){ 
    console.log("inside the mouse enter handler");
});

我试过这个,但它在IE中不起作用:

 $this.bind('mouseenter', function(){
        console.log("inside the mouse enter handler");
    });

我需要它至少在IE 9中工作。

3 个答案:

答案 0 :(得分:0)

console.log或至少console会在IE上给您一个错误...因此,您的javascript无效...尝试使用alert ...

答案 1 :(得分:0)

无法理解你的结局有什么问题。 我试过这个,它对我来说很好。

enter image description here

答案 2 :(得分:0)

如果您的浏览器控制台未打开,

console.log将返回js错误。它将在任何浏览器中发生,而不仅仅是IE。可能你在没有打开浏览器控制台的情况下,在浏览器控制台打开和IE的情况下尝试了FF和chrome。尝试打开IE中打开的浏览器控制台/使用alert()测试你的功能/直接编写你需要的功能。

希望它有所帮助!!!