// 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.
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn