Trigger a click event on an inner element

前端 未结 14 658
后悔当初
后悔当初 2020-12-29 07:53

A row in a table where each first cell contains a link needs to be clicked and open a url.

14条回答
  •  一个人的身影
    2020-12-29 08:13

    My usecase was to trigger a click when a -element was clicked. Checking the type of the target element solves the recursive call problem.

    $('#table tbody td').click(function(e){
        if ($(e.target).is('td')) {
            $(this).find('input').trigger('click');
        }
    });
    

提交回复
热议问题