如果我将此样式用于<body>
onmousedown='return false;' onselectstart='return false;'
是否可以通过使用javascript输入textareas并选择来提供异常? 如果是,那么你可以告诉我怎么样?
答案 0 :(得分:2)
实际上,您可以禁用文本选择,而无需繁琐的JavaScript事件处理程序。请在此处查看我的回答:How to disable text selection highlighting using CSS?
摘要:在IE中使用CSS和unselectable
expando。
CSS:
*.unselectable {
-moz-user-select: -moz-none;
-khtml-user-select: none;
-webkit-user-select: none;
-o-user-select: none;
user-select: none;
}
HTML:
<div id="foo" unselectable="on" class="unselectable">...</div>
答案 1 :(得分:0)
您需要阻止event bubbling文本框并选择。
您可以使用:input
选择器选择所有输入,文本区域,选择和按钮元素。
像
这样的东西$(":input").bind("mousedown", function(e){
e.stopPropagation();
});