How to get the id of the element clicked using jQuery this question have the answer of get the id of clicked element.
But it gives the all id.
For example
<div id="major">
<div id="two"> </div>
</div>
When clicking the div two
I want to get the id
only one which is two
. But the following script will give parent id also.
$("body").on('click','div',function()
{
alert(this.id);
}); //It alerts the two and major. But i want two only.
For this, purpose i tried to put the some undeclared function it gives result what i expect. For example
$("body").on('click','div',function()
{
alert(this.id);
mkh(); #undeclared function
});
Is there any inbuild method for to do it.? JS Fiddle