Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Getting the ID of the element that fired an event using JQuery


Is there any way to get the ID of the element that fires an event?



I'm thinking something like:




<html>
<head>
<script type="text/javascript" src="starterkit/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("a").click(
function(){
var test = caller.id;
alert(test.val());
}
);
});

</script>
</head>
<body>
<form class="item" id="aaa"><input class="title"></input></form>
<form class="item" id="bbb"><input class="title"></input></form>
</body>
</html>



Except of course that the var test should contain the id "aaa" , if the event is fired from the first form, and "bbb" , if the event is fired from the second form.



Can anyone help with this?


Source: Tips4all


This post first appeared on Cisco Exploration CCNA 4.0, please read the originial post: here

Share the post

Getting the ID of the element that fired an event using JQuery

×

Subscribe to Cisco Exploration Ccna 4.0

Get updates delivered right to your inbox!

Thank you for your subscription

×