In this tutorial, We will learn how to get the tag name in jquery. You can select to class or id that to get to the tag name.
Example:
<html>
<head>
<title>jQuery Get Tag Name</title>
</head>
<body>
<p id="my-id">
This is paragrah tag
</p>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var $tag = $('#my-id').get(0).tagName; //'p'
alert($tag);
});
</script>
</body>
</html>
Output:
p |
Thanks, May this example will help you.