0

ドロップダウンを作成しています。「Contact」をクリックすると、巨大な連絡先ボックスが降りてきます。「閉じる」をクリックすると消えます。この機能は機能します。

私が必要とするのは、フォームが開いたらリスト項目のバインドを解除することですが、フォームを閉じたら再度有効にします。

以下のコード。

jQuery(document).ready(function() {

 jQuery("#header ul.menu li:last-child").addClass("open");

 jQuery("#header ul.menu li.open").click(function() {

  jQuery(this).unbind("click");

  jQuery("#contact").animate({marginTop:'+=426px'}, 2000);

  return false;

 });

 jQuery("#contact a#close").click(function() {

  jQuery("#contact").animate({marginTop:'-=426px'}, 2000);

  jQuery("#header ul.menu li:last-child").live("click", function() {

  });

  return false;

 });

});
4

1 に答える 1

2

.unbind()/への関数参照を指定する必要があります.bind()

function click_handler() { 
    // do something
}

jQuery("#header ul.menu li.open").click(function() {
   jQuery(this).unbind("click", click_handler);

   jQuery("#contact").animate({marginTop:'+=426px'}, 2000);

   return false;
});

// some code

jQuery("#header ul.menu li.open").bind('click', click_handler);
于 2011-01-24T21:59:28.053 に答える