jquery使用技巧

1. 禁用右键点击(Disable right-click)

 1 <!DOCTYPE html>
 2 <html>
 3 <head>
 4 <meta charset="UTF-8">
 5 <title>Insert title here</title>
 6 <script type="text/javascript" src="js/jquery.min.js"> </script>
 7 </head>
 8 <body>
 9     <div>div</div>
10 </body>
11 <script type="text/javascript">
12 //     $(function(){
13 //         $(document).bind("contextmenu",function(e){//bind 为绑定参数
14 //         return false;
15 //         });
16 //     });
17     $("div").contextmenu(function(){
18         alert("pk"); //点击右键触发事件
19         return false;//取消默认行为
20     });
21 </script>
22 </html>

2.新窗口打开

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="js/jquery.min.js">
    
</script>
</head>
<body>
    <a href="http://blog.csdn.net/zhaoyazhi2129/article/details/8183793">ok</a>
</body>
<script type="text/javascript">
    $("a").attr("target","_blank")
</script>
</html>

 

posted on 2017-01-03 12:16  老邱2  阅读(110)  评论(0编辑  收藏  举报

导航