我的 style.cursor ='pointer' 当悬停到按钮时不起作用。有人可以帮助我如何实现这一目标吗?提前非常感谢您
(function() {
'use strict';
// Function to launch a webpage
function launchWebpage() {
const targetURL = 'https://example.com/';
window.open(targetURL, '_blank');
}
const launchButton = document.createElement('button');
launchButton.textContent = 'WebPage';
launchButton.style.position = 'fixed';
launchButton.style.top = '12px';
launchButton.style.right = '913px';
launchButton.style.background = '#F28C28';
launchButton.style.color = 'black';
launchButton.style.padding = '8px';
launchButton.style.border = 'none';
launchButton.style.borderRadius = '5px';
launchButton.style.cursor = 'pointer';
launchButton.style.fontWeight = 'bold';
launchButton.style.fontSize = '14px';
launchButton.style.fontFamily = 'Arial';
document.body.appendChild(launchButton);
// Add event listener to the button
launchButton.addEventListener('click', launchWebpage);
})();
代码在我的系统上运行得非常好。如果您可以使用codesandbox或任何其他在线IDE与我分享整个代码并重现您遇到的相同问题,我可以帮助您。