Skip to main content

How to get html tag name of an html element using jQuery

Some times it is needed to get the tag name of an element. You can use below mentioned script to get that.
<html>
<head>
<script src="jquery-1.5.1.min.js" type="text/javascript"></script>
<script>
  $(document).ready(function () {

    alert($('#someElement').attr('tagName'));

  )};
</script>
<body>
<a  href="#">click to get tag name </a>
<div id= 'someElement'>
You want tag name of this element.
</div>
</body>
</html

Comments