Disable right click on Image in jQuery

Last Reply 8 months ago By dharmendr

Posted 8 months ago


i have a website where i have images i see people do right click on image and check the exact path of image i want to stop right click on my images so user cannot see the exact path of images. please advice

Posted 8 months ago Modified on 8 months ago

Hi nauna,

Refer below code.


<div id="dvDetails">
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    <script type="text/javascript">
        $('#dvDetails').on('contextmenu', 'img', function (e) {
            return false;
    <img src="https://i.imgur.com/6LLBMoM.jpg" alt="Alternate Text" />