hguser
hguser

Reputation: 36068

text select when drag in javascript

When I make an element in the page draggable,and once I drag it,text outside this element will be selected.

I wonder why and how to prevent this?

Here is my example:

When I drag the gray div and over the paragraphs as fast as possible,the text of the paragraphs will be selected.

Upvotes: 1

Views: 452

Answers (1)

Ibu
Ibu

Reputation: 43850

you need to prevent the default behaviour

trigger.onmousedown = function(e) {
    this.style.cursor = "move";
    e.preventDefault(); // this line
    ...
}

Fiddle

Upvotes: 2

Related Questions