1

私は現在、このビットの Jquery を使用しています。

$(".option5").toggle(
function () {
    $(this).addClass("red"),
    $("#check5").attr('checked',true),
    $(".option5").unbind('mouseenter');
  },
function () {
    $(this).removeClass("red"),
    $("#check5").attr('checked',false),
});

最初の関数では、mouseenter の .unbind を追加しました。これはまさに必要なことを行いますが、次の関数では、ホバー (mouseenter mouseleave) を関数にバインドするために何を入れますか。いくつかのオプションを試しましたが、私が持っているホバー機能には戻りません。

4

1 に答える 1

2
$(document).ready(function(){

$(".option5").bind("refreshMouseEnter", function(event){
  $(this).mouseenter(function(event){
    //do your work
  });
}).bind("refreshMouseLeave", function(event){
  $(this).mouseleave(function(event){
   //do your work
  });
}).toggle(
function () {
    $(this).addClass("red"),
    $("#check5").attr('checked',true),
    $(".option5").unbind('mouseenter');
  },
function () {
    $(this).removeClass("red"),
    $("#check5").attr('checked',false),
///be very sure you want this selector!!! i just copied from above...
    $(".option5").trigger('refreshMouseEnter');
}).trigger("refreshMouseEnter").trigger("refreshMouseLeave");
});
于 2011-10-05T01:24:24.420 に答える