Monday, 13 January 2014

jQuery Plugin will disable text selection for Android and iOS devices

<script>
$(document).ready(function(){

   $('.notselectable').disableSelection();
    
});
// This jQuery Plugin will disable text selection for Android and iOS devices.

$.fn.extend({
    disableSelection: function() {
        this.each(function() {
            this.onselectstart = function() {
                return false;
            };
            this.unselectable = "on";
            $(this).css('-moz-user-select', 'none');
            $(this).css('-webkit-user-select', 'none');
        });
    }
});
</script>
Thanks for Ref: // Stackoverflow Answer: http://stackoverflow.com/a/2723677/1195891

No comments:

Post a Comment

KISS, DRY, SOLID, YAGNI — A Simple Guide to Some Principles of Software Engineering and Clean Code

1 — KISS (Keep It Simple, Stupid)  Simplicity triumphs over complexity. Direct and clear codes are better for developing, maintaining, and s...