I have a problem understanding what is wrong here. I use jQuery to find an element, but I fail finding the element's parent without using jQuery:
$(".selectbox").on("click", function(e) {
e = e || window.event;
var eTarget = e.target || e.srcElement;
find_parent(eTarget);
});
using above to call find_parent function works:
function find_parent (el) {
element_parent = el.parentElement;
}
but if use this to call find_parent it fails:
function someFunction {
selectBoxEl = $(".xyz").find('.selectbox');
find_parent (selectBoxEl);
}
I am not looking for the solution of "why not using jQuery parent()" - and it works fine. I am trying to understand why normal DOM methods don't work on an element returned by jQuery and what I am doing wrong.
Edit:
Sample code above is not the actual code being used, but a very simplified version to illustrate my question. The actual find_parent()
function is a long and complicated piece that goes through many elements and their parents for various updates and it doesn't use jQuery. I want to leverage that code and not duplicating it for my need in the sample function someFunction()
.