سؤال

I want to disable right clicks on any images.

This works fine, but only for the static images.

$('img').bind('contextmenu', function(
    return false;
});

How can I prevent right clicking on images which are added dynamically?

هل كانت مفيدة؟

المحلول

You can use .on() with a delegated event:

$(document).on("contextmenu","img",function(){ return false;});
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top