Question

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:

 editor.insertText("\"≥\"");

to an onclick event. I want to add that snippet to an inline div but I keep getting an "Uncaught SyntaxError: Unexpected token (" error from the below div:

<div style="background-color:red; width:50px; height: 50px;" onclick='function () { editor.insertText(\\≥\\); }'></div>

......What am I doing wrong?

Was it helpful?

Solution

Try this:

<div style="background-color:red; width:50px; height: 50px;" onclick='editor.insertText("\"≥\"");'></div>

OTHER TIPS

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>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top