인라인 OnClick 이벤트는 "Uncacked SyntaxError : 예기치 않은 토큰 ("오류
-
02-01-2020 - |
문제
이 외부에서 작동하는 버튼이 있지만 정말 정상적인 Div와의 행동을 정말로 복제하고 싶습니다.이렇게하면 이렇게 할 수 있습니다.
editor.insertText("\"≥\"");
.
onClick 이벤트에.이 스 니펫을 인라인 Div에 추가하지만 아래 Div에서 "Uncaught SyntaxError: Unexpected token (
"오류가 계속 발생합니다.
<div style="background-color:red; width:50px; height: 50px;" onclick='function () { editor.insertText(\\≥\\); }'></div>
.
...... 나는 무엇을 잘못하고 있습니까?
해결책
시도 :
<div style="background-color:red; width:50px; height: 50px;" onclick='editor.insertText("\"≥\"");'></div>
. 다른 팁
onClick 속성에서 직접 함수를 포함하는 경우이 기능을 호출해야합니다. 이와 같이 즉시 함수를 사용해야합니다. 아래에서는 먼저 편집기가 무엇인지 정의해야합니다
<div style="background-color:red; width:50px; height: 50px;" onclick='(function () { editor.insertText("\\≥\\"); }());'></div>
. 제휴하지 않습니다 StackOverflow