I’m trying to find the closest img next to some element. This element could be anything from h1 to a div. When finding this img I would like to append this to a div. This doesn’t work for me:
img = $(this).parent().find('img').attr('scr');
$('#result').append('<img src="' + img + '" />');
Don’t know why this doesn’t work.
Use a combination of
closest()and:has().