How to find parent's tag name

How to find parent's tag name

I want to check if the image wrapped by a tag, so I write the code like
  1. $('img').each(function() {
  2. console.log($(this).parent().tagName);
  3. });
but it seems not work, how to do it?