// Parameter obj: jquery object of the element whose text is to be disabled
// Parameter enabled: true, selectable; false, not selectable
function setSelectable(obj, enabled) {
if(enabled) {
obj.removeAttr("unselectable").removeAttr(" onselectstart").css("-moz-user-select", "").css("-webkit-user-select", "");
} else {
obj.attr("unselectable" , "on").attr("onselectstart", "return false;").css("-moz-user-select", "none").css("-webkit-user-select", "none") ;
}
}
The principle is as follows:
ie, you can set the handler function (return false;) of the event selectstart Disable selected text
Under ff and chrome, it can be controlled through css
As for the unselectable attribute, it can be seen as a supplementary means to adapt to as many browsers as possible.