Aisys
Aisys

Reputation: 43

change button onmouseover to onclick

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!

Upvotes: 0

Views: 52

Answers (1)

Zuyas
Zuyas

Reputation: 182

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

Upvotes: 1

Related Questions