2012-11-23 11 views
1

我想禁用一般頁面上的右鍵單擊,但每個圖像上都有一個自定義的jquery對話框。現在,img id被傳遞給事件,所以當菜單相同時,它會爲每個圖像提供不同的結果。我如何在JQuery中表達所有的類但不是這個?

所以我要綁定的非圖像我一般上下文菜單以外的所有IMG類=「形象」 ...

讓我怎麼表達$(!圖片)???

編輯 我查了一下不是功能。我正在使用它:但是即使在照片上,我仍然可以獲得一般幫助。

<script> 
    $(document).ready(function() { 

    $('*').not('.public-photo').bind("contextmenu", function (event) { 
     $("div.custom-menu").hide(); 
      event.preventDefault(); 
      $("<div class='custom-menu'>General Help</div>") 
       .appendTo("body") 
       .css({top: event.pageY + "px", left: event.pageX + "px"}); 
     }); 
     $('*').not(".public-photo").bind("click", function (event) { 
      $("div.custom-menu").hide(); 
     }); 
}); 
+1

http://api.jquery.com/not-sel ector/ – speti43

+1

我不建議禁用右鍵單擊並在圖像上顯示消息。如果您有版權內容,您不想訪問下載,請不要通過網絡訪問它。 – Curt

+0

嗨,它不是用於保護網頁內容。我想將其用作用戶的幫助功能。顯示我的自定義jQuery對話框 – Joe

回答

1

爲了讓每一個元素的圖像除外,試試這個:

$('*:not(.image)').dialog({ 
    // dialog setup... 
}); 

或者:

$('*').not('.image') 
0

您可以使用:not()選擇這樣做,是這樣的:

$(':not(.image)') 

還是.not()方法是這樣的:

$('<your container>').not('.image') 
0

所有除IMG類圖像:

使用CSS不僞選擇器:

$('*:not(img.image)') 

使用jquery未方法

$('*').not('img.image') 
相關問題