I want the following structure
<div class="test">
<div class="test1">
</div>
</div>
I am trying to right down click event on test1
$(".test .test1").click(function()
{
});
but it's not binding.
Any help?
I want the following structure
<div class="test">
<div class="test1">
</div>
</div>
I am trying to right down click event on test1
$(".test .test1").click(function()
{
});
but it's not binding.
Any help?
You need:
$(".test .test1").click(function() {
// Your code to handle when .test1 inside .test is clicked
});
or if you want to trigger click event on this element, then you can use .trigger():
$(".test .test1").trigger('click');
Also, remember to add your code inside DOM ready handler:
$(function() {
$(".test .test1").click(function() {
// Your code here
});
});
If your element are added dynamically to the DOM, you need to use event delegation:
$('body').on('click', '.test .test1' , function() {
// Your code here
});