Within my function, I am assigning an onclick event to every node of a specific type in the document, based on the given node parameter.
After that, I aim to target the element that was clicked and "bubble up" by applying an effect to the parent node selected using the provided selector.
The challenge lies in determining what type of selector is being used - whether it's a class, tag, ID, or something else.
So how should I compare target
with the selector value within the ** portion?
function myFunc(node, event, selector){
var elements = document.querySelectorAll(node);
for (var i = 0; i < elements.length; i++){
elements[i].onclick = function(event){
var target = event.target;
while (target != node){
**if (target == selector) **
applyEffects(target);
}
target = target.parentNode;
};
}
}
It's worth mentioning that JQuery is off-limits, as per the requirements of this assignment. (This question does not pertain directly to the homework itself).