Since the <div> element is the immediate parent of your <input> element, you can use the aptly-named parent () method
$("#ahBkMj").parent().remove();
In general, if you want the first ancestor to match the selector, you can use the closest () :
$("#ahBkMj").closest("div").remove();
Note, however, that closest() includes the element itself in its search.
FrΓ©dΓ©ric hamidi
source share