How to disable Firefox's default drag and drop on all images behavior with jQuery?

Viewed 34065

Firefox has this annoying behavior that it let's the user drag and drop any image element by default. How can I cleanly disable this default behavior with jQuery?

7 Answers

If Javascript is an optional requirement, you can try with CSS

.wrapper img {
    pointer-events: none;
}

You can cover your image with an empty div element:

.img-container{
    position: relative;
}
.prevent-drag{
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: 2;
}

<div class="img-container">
    <div class="prevent-drag"></div>
    <img src="" />
</div>
Related