Inline onclick event returns a “Uncaught SyntaxError: Unexpected token ( ” error

后端 未结 2 1171
无人及你
无人及你 2021-01-27 19:07

I have a button that works outside of this, but I really want to replicate the actions with just a normal div. I can do so by just adding this clickhandler:

 ed         


        
相关标签:
2条回答
  • 2021-01-27 19:41

    Try this:

    <div style="background-color:red; width:50px; height: 50px;" onclick='editor.insertText("\"≥\"");'></div>
    
    0 讨论(0)
  • 2021-01-27 19:52

    You have to Invoke the function, if you are including the function directly in onclick attribute, you have to use immediate function like this, though below you have to define what editor is first

    <div style="background-color:red; width:50px; height: 50px;" onclick='(function () { editor.insertText("\\≥\\"); }());'></div>
    
    0 讨论(0)
提交回复
热议问题