热门关键字:
jquery > jquery教程 > jquery教程 > jQuery有选择性的禁止文本选中

jQuery有选择性的禁止文本选中

349
作者:管理员
发布时间:2020/3/3 14:50:17
评论数:0
转载请自觉注明原文:http://www.jq-school.com/Show.aspx?id=958
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="http://www.softwhy.com/" />
<title>蚂蚁部落</title>
<style type="text/css">
html,body{height:100%}
div{
  width:150px;
  height:50px;
  background:#CCC;
}
</style>
<script type="text/javascript" src="mytest/jQuery/jquery-1.8.3.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  (function($){
    $.fn.disableSelection=function(){
      return this.attr('unselectable','on')
      .css({'-moz-user-select':'-moz-none',
        '-moz-user-select':'none',
        '-o-user-select':'none',
        '-khtml-user-select':'none',
        '-webkit-user-select':'none',
        '-ms-user-select':'none',
        'user-select':'none'})
      .bind('selectstart', false);
    };
  })(jQuery);
  $(':not(input,select,textarea)').disableSelection();
})
</script>
</head>
<body>
<div id="thediv">蚂蚁部落</div>
<textarea></textarea>
</body>
</html>



如果您觉得本文的内容对您的学习有所帮助:支付鼓励



关键字:jQuery
友荐云推荐