我正在尋找一種方法來判斷按鈕是否作為一種狀態被按下 - 請注意,這不是在按下按鈕時觸發動作的 onclick 功能。這是 js 代碼(https://jsfiddle.net/tearex/812rkLpt/14/)。代碼 <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" /><script src="https://code.jquery.com/jquery-1.11.1.min.js"></script><script src="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script><input type="button" name="nomen" ID="first" value="1" onclick="one()"> <input type="button" name="omen" ID="second" value="2" onclick="two()"> JSfunction one(){if (document.getElementById('first').clicked=="clicked") {alert('clicked')}one();}function two(){document.getElementById('first').click();if (document.getElementById('first').clicked=="clicked") {alert('clicked')}}按下按鈕 1 應觸發對按下按鈕的檢查。按下按鈕 2 應該會導致按下按鈕 1 并發出確認這已發生的警報。兩者都不起作用。那有什么問題?
按下 HTML 按鈕 - 使用 Javascript 檢查狀態(單擊時不觸發)
慕妹3146593
2022-10-08 17:02:58