gpt4 book ai didi

javascript - 将按钮 onmouseover 更改为 onclick

转载 作者:行者123 更新时间:2023-12-02 22:03:52 25 4
gpt4 key购买 nike

changeButton.className = 'change button types-popup';
const changePopup = document.createElement('div');
changeButton.appendChild(changePopup);
changeButton.onmouseover = e => {
if (!e.target.classList.contains('types-popup')) return;
changePopup.innerHTML = '':
renderTypes(changePopup, type => {
defectData.action = 'update';
defectData.type = type.id;
textDiv.children[0].innerText = type.description;
closePopups();
});

我完全不懂js。那么你可以帮我将这个 onmouseover 更改为 onclick 打开/关闭吗?谢谢!

最佳答案

只需将 changeButton.onmouseover 更改为 changeButton.onclick

参见onclick

changeButton.className = 'change button types-popup';
const changePopup = document.createElement('div');
changeButton.appendChild(changePopup);
changeButton.onclick = e => {
if (!e.target.classList.contains('types-popup')) return;
changePopup.innerHTML = '':
renderTypes(changePopup, type => {
defectData.action = 'update';
defectData.type = type.id;
textDiv.children[0].innerText = type.description;
closePopups();
});

关于javascript - 将按钮 onmouseover 更改为 onclick,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59783815/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com