make input element draggable after disabling it

来源:互联网 发布:剑三成男捏脸数据大 编辑:程序博客网 时间:2024/06/05 15:28

make input element draggable after disabling it

up vote0down votefavorite

I have an <input> element which I have "disabled" (using disabled:true) and for which I have removed selection (using .disableSelection()).

The <input> element is therefore not much more than a picture: non-interactive pixels. Because of that, I should be able to make the element draggable, as there is no chance of conflict with any anotherclick event.

I've tried .draggable() naively, but that doesn't work: http://jsfiddle.net/E26dY/



1 Answer

activeoldestvotes
up vote2down voteaccepted

First you need to un-disable input and then use .draggable({cancel: null}) in your js. Live example: http://jsfiddle.net/E26dY/8/

HTML:

<input />

jQuery/JavaScript:

$('input').val('Drag me!').disableSelection().css('webkit-user-select','none').draggable({cancel: null});
share|improve this answer

原创粉丝点击