When viewing the internet on a mobile phone, the user will not be able to ‘cut and paste’ or select text. This can be annoying sometimes when you need to send share details of a web page, but at other times it may be needed, such as when you have a scrollable web page but when the user scrolls, it selects the text by accident, instead of scrolling. This code attached to the element will make the text unselectable and scroll once again.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script src="https://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> <style> #callback { background-color: red; } </style> <script> $(document).ready(function(){ $('#callback') .draggable({ start: function(e, ui) { alert('Dragging Started'); }, }); }); </script> </head> <body> <div id="callback" class="demodiv">This <div> has a callback for the drag action.</div> </body> |