If you look up Jquery's API, you will find that this seems to be a blind spot of Jquery. There is no clear explanation on how to get the name of the HTML tag. If you use
$("H1") directly. tagName
cannot get a value like "H1" in this way, it seems that it will only get "undiffed".
Later I discovered that Jquery actually regards tagName as one of its attributes, which is interesting.
So use
$("H1").attr("tagName")