Pass javascript function as data-* attribute and execute

前端 未结 4 799
甜味超标
甜味超标 2021-02-11 18:21

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

4条回答
  •  抹茶落季
    2021-02-11 18:49

    Simply with :

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

提交回复
热议问题