我尝试在img标签上绑定click和animate函数。它在firefox中运行良好。但IE出了问题。所以我简化了代码并仅针对点击进行了测试。甚至点击功能也没有被删除。这是我的img标签的点击功能,类为'arrowimg'。

$('.arrowimg').click(function(){alert("Show me")});

我在FF中收到此警报但在IE中没有可能出现的问题?

编辑:这是我为img标签生成的HTML代码

<img src='http://localhost/gowri/Project/SS4U/public/images/symbols/advartise_right_arrow_NEW.gif' id="next" class="arrowimg" alt="advartise_right_arrow" />
有帮助吗?

解决方案

确保它在文档就绪事件中,然后用半冒号结束警报。

$(document).ready(function() {
    $('.arrowimg').click(function(){alert("Show me");});
});

编辑:看起来你的标记有些东西:

'advartise_right_arrow_NEW.gif'附近有双引号。

应该是这样:

<div id="nextdiv">
    <img src="<?php echo _SS4U_SYM.'advartise_right_arrow_NEW.gif'; ?>" 
        id="next" class="arrowimg" alt="advartise_right_arrow"/>
</div>

其他提示

通常,IE6应该能够处理这个问题。确保您为选择器获得任何匹配

alert($('.arrowimg').length);

如果没有,可能会在早期阶段出现其他问题。

试试这个,

$('.arrowimg').click(function(event){
   event.preventDefault();
   alert("Show me");
});

仅供将来参考:检查您的jQuery版本和您的jQuery语法

使用jQuery 1.6和

 $('#elem_id').on('click', function(){ }); 
由于 on 功能,

正在工作。错误:'undefined'不是函数

使用

 $('#elem_id').click(function(){ }); 

代替或升级到更新的jQuery版本。 https://developers.google.com/speed/libraries/devguide#jquery

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top