テキストエリアで入力した内容を、コンソールに出力したいのですが、下の画像のようにエラーがでてしまいます。
エラー内容では、valueを読み込むことができないと書いてありますが、どこをなおせばいいのかわかりません。
質問
エラーを直すためには、どこを修正すればいいでしょうか?
大変恐縮ですが、ご回答いただけると幸いです。
よろしくお願いします。
念のために、URLを掲載させていただきます。
HTML
<div class="bar2"> <p class="opinion"> ご意見箱 </p> <section> <form action="#" id="form"> <textarea class="text"></textarea> <input type="submit" name="my_name" value ="送信" class="submit"> </form> <p id= "output"></p> </section> </div>
CSS
.bar2{ width:210px; height:280px; font-size:14px; display:inline-block; background-color:#fff2de; position:relative; } .opinion{ position:absolute; top:5px; left:70px; } .text{ position:absolute; top:50px; left:15px; height:170px; } .submit{ position:absolute; top:85%; left:37%; }
Javascript
<script> document.getElementById('form').onsubmit = function() { console.log('クリックされました'); }; </script> <script> document.getElementById('form').onsubmit = function() { var search = document.getElementById('form').word.value; document.getElementById('output').textContent = '『' + search + '』の検索中...'; return false; }; </script> </body> </html>
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。