我正在使用 Electron 框架进行元素。我有一个HTML文件,一个CSS文件和一个Javascript文件。我遇到的问题是,当我将鼠标悬停在按钮上时,即使我在CSS代码中为其指定了执行此操作的属性,也不会弹出手形指针图标。
这是我的HTML代码:
<button style="background: url(images/cross.svg);" alt="exit" id="exit_button"></button>
这是我的CSS代码:#exit_button{
cursor: pointer;
width: 15px;
border: 0px;
height: 15px;
margin: 0%;
padding: 0%;
position: absolute;
top: 5px;
right: 5px;
}
这是我的Javascript代码://variables
const remote = require('electron').remote;
const exit_button = document.getElementById("exit_button");
//Firing functions
exit_button.addEventListener('click', close_window);
//functions
function close_window() {
console.log("exit_button clicked, window closing..."); //This DOESN'T print
var current_window = remote.getCurrentWindow();
current_window.close();
};
分配给exit_button
的click事件与指针问题都不起作用。提前致谢。
最佳答案
我尝试将您的代码放在JSFiddle中,但没有任何问题。也许还有其他矛盾之处?使用开发人员工具并逐个禁用样式以找到罪魁祸首。
关于javascript - 当我将鼠标悬停在html按钮上时, Electron 中的单击事件不起作用并且鼠标图标没有更改?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66172360/