let say I have a parent element which has so many nested child elements inside of itself:
3条回答 无人及你 (楼主) 2020-12-05 05:11 If your elements have grandchildren, there is a better way to get just the child. Note the greater than sign. $('.parent > .child').click(function() { // This will be the child even if grandchild is clicked console.log($(this)); }); 0 讨论(0) 查看其它3个回答 发布评论: 提交评论 加载中... 验证码 看不清? 提交回复 热议问题
If your elements have grandchildren, there is a better way to get just the child. Note the greater than sign.
$('.parent > .child').click(function() { // This will be the child even if grandchild is clicked console.log($(this)); });