Using jQuery to trigger html onclick event

后端 未结 4 1628
天命终不由人
天命终不由人 2020-12-05 10:37



        
4条回答
  •  旧时难觅i
    2020-12-05 11:04

    Just don't return false and it'll get called:

    $("#test_default").click(function (e) {
      //hi!
    }).click();
    

    If you want to prevent a default action, use e.peventDefault() instead, which won't kill the event. Also, with respect to your inline onclick handler (why not do it all unobtrusively?), I strongly recommend against using with.

提交回复
热议问题