禁止从 HTML 页面拖动图像 [英] Disable dragging an image from an HTML page

查看:45
本文介绍了禁止从 HTML 页面拖动图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在我的页面中放一张图片.我想禁用该图像的拖动.我正在尝试很多事情,但没有帮助.有人可以帮我吗?

I need to put an image in my page. I want to disable dragging of that image. I am trying lot of things but no help. Can somebody help me out ?

我不想将该图像保留为背景图像,因为我正在调整图像大小.

I don't want to keep that image as a background-image because I am resizing the image.

推荐答案

我自己尝试过,发现这是有效的.

I tried myself and found this is working.

$("img").mousedown(function(){
    return false;
});

我确信这会禁用所有图像的拖动.不确定它会影响其他东西.

I am sure this disables dragging of all the images. Not sure it effects something else.

这篇关于禁止从 HTML 页面拖动图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆