I have all the scripts I need in place, but just need to complete this function, and without using a JS library:
function get_main_parent (elem) {
//get the parent of the element (elem) that has the 'main-class' class and add a class to the first <div> in that parent element
}
The below will have an element triggered by click or focus, and that element will be passed into the above function (I only need to complete the function):
…basically the event could be triggered anywhere, and any number of elements deep. The function just needs to receive an element and go up the DOM tree to find the div with ‘main-class’ as the class and then step forward one to find the first <div> and add a class to that.
I’m sure there’s a better way to explain this. Thanks.