在jQuery中识别被点击的目标的子元素
我试图弄清楚如何右键单击表中的任何地方,在tr
标签上有一个事件监听器,并将click()
命令向下传递给子button
。
jQuery(".catcher").contextmenu(function (e) { e.target.**FIND CHILD BUTTON**.click(); });
table { border: 1px solid red; width: 200px; height: 200px; }
您需要使用jquery find
方法搜索任何深度的第一个子实例
jQuery(".catcher").contextmenu(function(e) { $(this).find('button').click(); return false; });
table { border: 1px solid red; width: 200px; height: 200px; }
jQuery(".catcher").contextmenu(function (e) { //e.target.**FIND CHILD BUTTON**.click(); $(e.target).find('button').click() });
table { border: 1px solid red; width: 200px; height: 200px; }
请参阅此处数量是类名
($(e).parent().parent().find(".Qty").val()