By using below example we can get the id and anchor tag name using JQuery.
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
$(function () {
debugger;
var id = $('#links #active1').attr('id');
var linkName = $('#links #active1 a').text();
$('body').html('Id Name--------' + id + '<br />' + 'Name--------' + linkName);
});
</script>
</head>
<body>
<ul id="links">
<li id="active1"><a href="google.com" id="3">aspnettutorialonline.blogspot.com </a></li>
<li id="active2"><a href="yahoo.com" id="2">Yahoo </a></li>
<li id="Li1"><a href="facebook.com" id="A1">Facebook </a></li>
</ul>
</body>
</html>
Output:
![]() |
| Getting inside ul hyper link id and name using JQuery |

Post a Comment