1

I want to disable right click on the page in general but on each image has a custom jquery dialog. Now the img id is passed to the event so while the menu is the same it will give different results per image.

so I want to bind my generic context menu for non images for all except img class="image"...

so how do I express $(!.image) ???

EDIT I looked up the not function. I am using it like this: However I still get general help even on photos.

<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();
        });
 }); 
4

4 回答 4

1

To get every element excluding images, try this:

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

Or alternatively:

$('*').not('.image')
于 2012-11-23T14:36:18.237 回答
0
$('.yourSelector').not('.image')
于 2012-11-23T14:35:52.873 回答
0

You can do it using the :not() selector, like this:

$(':not(.image)')

Or the .not() method like this:

$('<your container>').not('.image')
于 2012-11-23T14:36:23.563 回答
0

对于除 img 类图像之外的所有图像:

使用 CSS 而不是伪选择器:

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

使用 jquery not 方法

$('*').not('img.image')
于 2012-11-23T14:39:14.543 回答