Flicker Images

Find programmers and grapic design experts at ScriptLance.com

Tuesday, December 27, 2011

How get tag name in Jquery



For finding any element tag name, we can get using following code.
Code
var tagName = $(this).get(0).tagName;

Example
<html>
<head>
<link href='css/custom-theme/jquery-ui-1.8.16.custom.css' rel='stylesheet' type='text/css'> 
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery-ui-1.8.16.custom.min.js"></script>
</head>
<script>
$("#new_button").button();
$("#new_button").click(function() {
var TagName = $(this).get(0).tagName; 
alert(TagName);
var ParentTagName = $(this).parent().get(0).tagName; 
alert(ParentTagName);
});
</script>

<body>
<div style="display: table-cell; float: right;"><a id="new_button">New</a></div>
</body>
</html>
iPhone_Case_Bear_3468x60banner
Share:

0 comments:

Post a Comment

Game Reviews

BTemplates.com

Powered by Blogger.

Search This Blog

Video Of Day

Find Us OIn Facebook

Blogroll

Contact

Tackle the Web with up to 5 new .COMs, $5.99 for the 1st year!

Advertisement