現在codemirrorを使ったシステムを作成しようと考えているのですが
codemirrorの使い方に困っています
codemirrorに入力された文字の正誤判定の条件文を仕込みたいのですが、
うまくできません
どこにどのように仕込めばいいでしょうか
よろしくお願いいたします
<!DOCTYPE html> <html> <head> <meta content="text/html; charset=UTF-8" http-equiv="content-type"> <title>Git Tutorial Level1</title> <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.2.0/codemirror.js"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.2.0/codemirror.css"/> <script src="sample1-2.js"></script> <link rel="stylesheet" href="sample1-1.css"> </head> <body> <div class="container"> <h1 style="text-align: center; font-size=500%">sample1-2</h1> <hr style="margin-left: auto; margin-right: auto;"> <div style="text-align: center;">これはcodemirror勉強用です。</p> <div id="textarea2"> <p><span id="text">./a.out</span>と入力しましょう。</p> <span id="intro"></span> </div> <p> </p> <div><textarea id="editor_js" rows="20" cols="60"></textarea></div> <script type="text/javascript"> CodeMirror.fromTextArea(document.getElementById("editor_js"), { lineNumbers: true}); </script> <br> <br> </div> </div> </body> </html>
<script> var i = 0, commands = [ 'text', 'text1', 'text2', 'text3' ]; var intro = [ "textの説明", "text1の説明", "text2の説明", "text3の説明" ]; $("#textarea1 textarea").keypress(function () { var lastLine = (this.value).substr((this.value).lastIndexOf("\n") + 1); if (lastLine == $("#text").text()) { $("#textarea2 p").html('次は、<span id="text">' + commands[i] + '</span>と入力しましょう<br>'); $("#intro").html(commands[i] + 'の説明: ' + intro[i]); i++; } }).change();
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。