内联Onlick事件返回“未捕获的语法错误:意外的令牌(”错误 [英] Inline onlick event returns a "Uncaught SyntaxError: Unexpected token ( " error

查看:131
本文介绍了内联Onlick事件返回“未捕获的语法错误:意外的令牌(”错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个按钮,在这之外工作,但我真的想复制的动作只是一个正常的div。我可以这样做只需添加这个点击处理程序:

  editor.insertText(\≥\); 

到onclick事件。我想将该代码段添加到内联div,但我继续得到一个未捕获的语法错误:意外的令牌(错误从下面的div:

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

...



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


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?

解决方案

Try this:

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

这篇关于内联Onlick事件返回“未捕获的语法错误:意外的令牌(”错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆