search

Home  >  Q&A  >  body text

angular.js - js click event onclick="", can the function name in quotes be a variable?

I added the li element like this

How to set click to cancelTaskEve()

仅有的幸福仅有的幸福2862 days ago724

reply all(3)I'll reply

  • 漂亮男人

    漂亮男人2017-05-15 17:00:06

    cancelTaskEve()
    It is best to use function cancelTaskEve(){}.
    var cancelTaskEve=function(){} This way of writing may cause problems if the function is used before it is declared.

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-05-15 17:00:06

    Okay, just do it like this
    <p onclick="cancelTaskEve()"></p>

    reply
    0
  • 滿天的星座

    滿天的星座2017-05-15 17:00:06

    ele.onclick = cancelTaskEve;

    reply
    0
  • Cancelreply