当前位置: 动力学知识库 > 问答 > 编程问答 >

ruby on rails - Safari/Chrome does not understand jQuery focus/blur on check boxes

问题描述:

Here's my javascript:

$(".more_info").hide();

$(".checkbox.has_info, .has_info").focus(function(){

$(this).parent().next().next().show("fast");

});

$(".checkbox.has_info, .has_info").blur(function(){

$(this).parent().next().next().hide("fast");

});

Note, that this works perfectly in Firefox/ IE7, IE8.

So far I have discovered that this is because Safari and Chrome do not accept the focus/blur events for check box or radio buttons. Anyone know a work around that still has the same effect?

网友答案:

Yes! Here it is folks! Amazing!

$(".more_info").hide();

var $info_items = jQuery('.checkbox.has_info, .has_info')
$info_items.click(function(){
  var $info_item = jQuery(this);
  $info_items.filter(function(index){
    return $(".hidden_text").css("display","block");
    }).not($info_item).parent().next().next().hide("slow");
  $info_item.parent().next().next().show("fast");
});
分享给朋友:
您可能感兴趣的文章:
随机阅读: