Ad

Change Button Onmouseover To Onclick

- 1 answer

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();
   });

I completely have no understanding js. So may you help me to change this onmouseover to onclick open/close? Thanks!

Ad

Answer

Just change the changeButton.onmouseover to changeButton.onclick

See 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();
   });
Ad
source: stackoverflow.com
Ad