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/

10-12 01:15