2016-03-26 12 views
0

私は画面ボディ閉じるボタン

の真ん中に浮かぶフォームを作ったそして、そのために私は

を閉じるには、ボタンをデザインしかし、私はマウスが閉じた形をクリックすると、画面上の任意の場所になりたいです

私のコード

$(".offer-close").click(function() { 
 
     $(".div-fix").fadeOut(500); 
 
    });
<div class="div-fix"> 
 
<div class="offer-shop"> 
 

 
    <div class="cur-package"> 
 
     <div class="offer-close"><i class="fa fa-times"></i></div> 
 
     <h6>Service</h6> 
 

 
     <div class="pack-b"> 
 

 
      <div class="pack-price">6500 <div> 
 
      <br> 
 

 
      <div class="pack-shop"><a href="#" target="blank">Buy</a></div> 
 
     </div> 
 
     <div class="pack-c">any ...</div> 
 
    </div> 
 
</div> 
 
</div>

例:フィードバックウェブサイト:http://cssdeck.com/

答えて

0

以下のスクリプトを追加すると、問題が解決されます。

$(document).mouseup(function (e) 
{ 
    var container = $(".div-fix"); 

    if (!container.is(e.target) // if the target of the click isn't the container... 
     && container.has(e.target).length === 0) // ... nor a descendant of the container 
    { 
     container.hide(); 
    } 
}); 

jsFiddle Demo

+0

コードが –

+0

デモ動作していない:https://jsfiddle.net/ehsanex/chf7osfs/ –

+0

@desallをこんにちは、私はあなたのコードにいくつかの変更があります。httpsを確認してください:// jsfiddle.net/chf7osfs/1/ – byJeevan

関連する問題