I was just wondering have anyone tried doing something like this(this is within a vuejs created method):
for (let i = 0; i < this.items.length; i++) {
let bar = document.createElement('div');
bar.className = this.items[i].colour;
bar.style.cssText = `width: ${this.items[i].weight}%`;
bar.setAttribute("mouseover", this.showBlock(500, false)); //not working
document.querySelector('.bar').appendChild(bar);
}
https://jsfiddle.net/phfilly/eywraw8t/167799/
I’m trying to add a hover mouse event(line 32) to the newly created element. Is there another way to achieve something like this?