[JS]jQuery でマウスの右クリックを禁止する方法
スポンサード
スポンサード
jQuery でマウスの右クリック動作を無効化する方法のご紹介です。
目次
body 要素全体にマウスの右クリック禁止を適用
<head> 内に、jqueryファイルと一緒に以下の記述を追加します。<script src="./jquery.min.js"></script> <script> $(function(){ $('body').on('contextmenu',function(e){ return false; }); }); </script>
特定の要素でマウスの右クリック禁止を適用
以下のように、content クラスを付与した特定の要素に対してマウスの右クリック禁止を適用してみます。<script src="./jquery.min.js"></script> <script> $(function(){ $('.content').on('contextmenu',function(e){ return false; }); }); </script>
スポンサード
コメント