簡體   English   中英

如何使用JavaScript或jQuery以編程方式觸發鼠標右鍵

[英]How to trigger mouse right click programmatically using javascript or jQuery

我需要使用javascript或jQuery觸發鼠標右鍵。 在這里我嘗試下面的代碼對我不起作用

 <div id="testing" style="height:500px;width:1000px;background-color:lime;"></div>
    <script>
   $(document).ready(function () {
     $('#testing').contextmenu();
     //or
     $('#testing').trigger({
        type: 'mousedown',
         which: 3
     });
    });
    </script>

能否請您提供任何相關信息。

 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <div id="testing" style="height:500px;width:1000px;background-color:lime;"></div> <script> $(document).ready(function () { $("#testing" ).contextmenu(function() { alert( "Right clicked" ); }); }); </script> 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM