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