I do believe this is a very stupid question and there's a very simple answer for it, but I didn't found a solution:
I have the following JavaScript function:
function setStatus(order, operation, status, elem){
elem.parent().$(".active").removeClass("active");
elem.addClass("active");
}
Elem is Image-element in my HTML which I'm sure is the right one by checking it's type with alert(elem);
The error I get is exactly what I expected:
Object #< HTMLImageElement> has no method 'parent'
I already know this is because elem is a DOM-element and not an JQuery-element which means that it's not possible to use functions like parent() and addClass(). How can I use all JQuery-function on my elem? Is there a way to convert a DOM-element to a JQuery-element? I found this question on the internet many times with this that should have been $(this), but $(elem) doesn't seem to work.
$(elem).siblings().removeClass("active").end().addClass("active");...?$(".active")?$(".active", $(elem).parent()).removeClass("active"); $(elem).addClass("active");alert() isn't the best way to log/debug code. Use instead console.log($(elem));