If you want to perform a function at the time to click on div, calling from the ID, this is the code:
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
$(document).ready(function () {
$('#firstdiv').click(function(){
/*I add alert for the example, but here is where you put your code*/
alert($(this).attr('id'));
});
</head>
<body>
<div id="firstdiv">div1</div>
</body>
In addition this is the information link with the function click () in jquery, has example of how to use it in different event on an element: https://api.jquery.com/click/
example calling the div inside table:
$("table div").click(function(){
/*I add alert for the example, but here is where you put your code*/
alert($(this).attr('id'));
});
Example calling with the tag div:
$('div').click(function() {
/*I add alert for the example, but here is where you put your code*/
alert($(this).attr('id'));
});
--body
<table>
<tr>
<td><div id="demo1"></td>
</tr>
</table>
And this is a post with good example:How can I get the ID of an element using jQuery?