Closed DRavenNISV closed 4 years ago
I implemented it this way, use event delegation bind event listener to TagCloud instance root element
var rootEl = document.querySelector('.content');
rootEl.addEventListener('click', function clickEventHandler(e) {
if (e.target.className === 'tagcloud--item') {
console.log(e.target.innerText);
// your code here
}
});
This works perfectly! Thank you very much for your dedication.
Hi mcc108!
Thanks again for taking the time to look at my previous issue. I have a single other question for you specific to my usage of the TagClouds.
I'm having a little difficulty understanding the source code of TagCloud.js. I was wondering how (or if) general onclick Events can be added to the tags of the cloud. I noticed that there is a handler for mousemove event for the changes in directions. I also noticed that when hovering over a tag a highlight is given as well as a 'clicking option'. Is there perhaps an option that I could add an eventlistener specific for the onclick events?
Thank you in advance.