CSS /JS to prevent dragging of ghost image?

Solution 1:

You can set the draggable attribute to false in either the markup or JavaScript code.

// As a jQuery method: $('#myImage').attr('draggable', false);
document.getElementById('myImage').setAttribute('draggable', false);
<img id="myImage" src="http://placehold.it/150x150">

Solution 2:

I think you can change your

img {
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -o-user-select: none;
  user-select: none;
}

into a

img {
  -webkit-user-drag: none;
  -khtml-user-drag: none;
  -moz-user-drag: none;
  -o-user-drag: none;
  user-drag: none;
}

Solution 3:

Try it:

img {
  pointer-events: none;
}

and try to avoid

* {
  pointer-events: none;
}

Solution 4:

This will disable dragging for an image in all browsers, while preserving other events such as click and hover. Works as long as any of HTML5, JS, or CSS are available.

<img draggable="false" onmousedown="return false" style="user-drag: none" />

If you're confident the user will have JS, you only need to use the JS attribute, etc. For more flexibility, look into ondragstart, onselectstart, and some WebKit tap/touch CSS.

Solution 5:

You can use a CSS property to disable images in webkit browsers.

img{-webkit-user-drag: none;}