I place the text on the image inside the label. If I drag the text and place it in a text box it automatically copies that text. But i don't want that to be happened. Please give me a hint to disable the mouse click and drag event on the text.
Asked
Active
Viewed 2,839 times
1
-
Have a look on this question http://stackoverflow.com/questions/7439042/css-js-to-prevent-dragging-of-ghost-image – styopdev Jun 01 '16 at 07:34
1 Answers
5
this help you :
<html>
<head>
</head>
<body>
<span id="txt" draggable="false">This is test</span>
<script>
var txt = document.getElementById("txt");
txt.addEventListener("click",function(event){event.preventDefault();})
txt.addEventListener("mousedown",function(event){event.preventDefault();})
txt.addEventListener("mouseup",function(event){event.preventDefault();})
txt.addEventListener("contextmenu",function(event){event.preventDefault();})
</script>
</body>
</html>

Ehsan
- 12,655
- 3
- 25
- 44
-
I don't have that privilege.. I need to earn 15 reputation for that but i did not earn yet ... – pretty Jun 01 '16 at 09:54