Pass javascript function as data-* attribute and execute

前端 未结 5 677
陌清茗
陌清茗 2021-02-11 18:31

We know such syntaxes as below, when defining a value for onClick attribute:

5条回答
  •  别那么骄傲
    2021-02-11 18:54

    Simply with :

     $("body").on("click","button.marker", function(e) {
         eval($(this).data("callback"));
     })
    

提交回复
热议问题