未捕获的类型错误:无法读取 null Javascript 的属性“innerHTML”

时间:2021-07-21 01:18:18

标签: javascript html css chatbot

任何人都可以解决这些错误是什么? 一直出现这个错误,不知道为什么

<块引用>

未捕获的类型错误:无法读取 null 的属性“innerHTML”。

**我的 Repl 链接是 https://replit.com/join/ninbjebtkd-techyashu007

             
               <div class="chatbox__messages">
                  <div>
                     <div class="messages__item messages__item--visitor">
                        Can you let me talk to the support?
                     </div>
                     <div class="messages__item messages__item--operator">
                        Sure!
                     </div>
                     <div class="messages__item messages__item--visitor">
                        Need your help, I need a developer in my site.
                     </div>
                     <div class="messages__item messages__item--operator">
                        Hi... What is it? I'm a front-end developer, yay!
                     </div>
                     <div class="messages__item messages__item--typing">
                        <span class="messages__dot"></span>
                        <span class="messages__dot"></span>
                        <span class="messages__dot"></span>
                     </div>
                  </div>
               </div>
               
            </div>
            <div class="chatbox__button">
               <button>button</button>
            </div>
         </div>
      </div>
      <script>
         var know = {
             "hello": "Hi",
             "how are you?": "Good",
             "john": "hi john",
             "": "hh"
             // You Can Add More Stuff Here - It is customizable. - you can add more than 3 
         };
         
         function talk() {
             var user = document.getElementById("messages__item messages__item--operator").value;
             document.getElementById("messages__item messages__item--visitor").innerHTML += user + "<br>";
             if (user in know) {
                 document.getElementById("messages__item messages__item--visitor").innerHTML += know[user] + "<br>";
             } else {
                 document.getElementById("messages__item messages__item--visitor").innerHTML +=
                     "I am not a genius , ask me something that I know!<br>";
             }
         }```

0 个答案:

没有答案