jquery assign onclick for li from a link

后端 未结 5 1006
长情又很酷
长情又很酷 2020-12-14 13:30

I have a list of items

5条回答
  •  我在风中等你
    2020-12-14 14:06

    $('.list li').click(function() {
        var launch = $('a.launch', this);
        if (launch.size() > 0) { eval(launch.attr('onclick')) }
    });
    

    Mario's solution will also work. Mine will take the child 's onclick event and execute it, on the actual click.

    Mario's solution will bind the 's onclick event to the li's on document load. Pick what suits you best.

提交回复
热议问题