var SELECTED_ELEMENT = null;
function getEl(mouse) {
var ev = mouse || window.event;
SELECTED_ELEMENT = ev.target || ev.srcElement;
}
document.onclick = getEL;
which works fine for most instances of click but i noticed some elements which were being stored in the "SELECTED_ELEMENT" field which shouldnt be.
With that said, i was thinking to do something like:
...
var ev = mouse || window.event;
var t_select = ev.target || ev.srcElement;
if ($(t_select).attr("class") == "derp"){
SELECTED_ELEMENT = t_select;
}
...
that way the code would only override the selected element if the selected element or one of its parents has the class "derp"
Maybe i could change the if statement to something like
if ($(t_select).closest(".derp").length > 0){SELECTED_ELEMENT = t_select; }
What do you all think?

New Topic/Question
Reply


MultiQuote


|