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

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

问题描述

我需要在我的网页中加入图片。我要禁用该图像的拖动。我试着很多事情,但没有帮助。有人可以帮我吗?



我不想将该图片保存为背景图片,因为我正在调整图片大小。


  

$(img)。mousedown(function(){
return false;
});

我确定这会禁用所有图像的拖动。不确定它影响别的东西。


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天全站免登陆