jQuery Tipsy不触发onclick IE [英] jquery tipsy not firing onclick IE

查看:62
本文介绍了jQuery Tipsy不触发onclick IE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jquery Tipsy插件在颜色样本图像上方显示颜色名称.

Hi I am using the jquery tipsy plugin to display colour names above colour swatch images.

当用户单击图像时,我试图触发一个复选框被选中/取消选中.

I am trying to trigger a checkbox to be checked/unchecked when a user clicks on the image.

$(document).ready(function(){
     $('.label_check_colour').click(function(){
        setupLabelColour();
     });
}

function setupLabelColour() {
     if ($('.label_check_colour input').length) {
          $('.label_check_colour').each(function(){ 
              $(this).removeClass('c_on');
          });
$('.label_check_colour input:checked').each(function(){ 
    $(this).parent('label').addClass('c_on');
        });                
    };
};

HTML

<div class="selectableSwatch">
      <label class="label_check_colour" for="colour_1"><input type="checkbox" id="colour_1" name="colour_id[]" value="1" /><img class="colour_tip_1" width="20" src="img/colour-palette/1" /></label>
</div>

一切在Firefox和Safari中都可以正常运行,但在IE8中却不行.

Everything works great in Firefox and Safari but not in IE8.

帮助...请.

推荐答案

请尝试更改此条件,

if ($('.label_check_colour input').length>0) {

在setupLabelColour函数中您有不需要的分号

and you have unwanted semi colons in setupLabelColour function

function setupLabelColour() {
     if ($('.label_check_colour input').length) {
          $('.label_check_colour').each(function(){ 
              $(this).removeClass('c_on');
          });
         $('.label_check_colour input:checked').each(function(){ 
             $(this).parent('label').addClass('c_on');
         });                
    }
}

并且您没有文档准备功能的右括号.这是完整代码 http://jsfiddle.net/HMk9V/10/.试试吧,我认为它现在正在工作.

And you do not have the closing parentheses of document ready function. Here is full code http://jsfiddle.net/HMk9V/10/ . Try I think it is working now.

这篇关于jQuery Tipsy不触发onclick IE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆