亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

為什么我的JavaScript顯然陷入了無限循環?

為什么我的JavaScript顯然陷入了無限循環?

郎朗坤 2021-04-14 13:15:30
我正在定義一個on'submit'事件,如下所示:HTML代碼是:<div class="messages">            <ul>                <li class="sent">                    <img src="/img/person1.png" alt="" />                    <p>How the hell am I supposed to get a jury to believe you when I am not even sure that I do?!</p>                </li>                <li class="replies">                    <img src="/img/botimg.png" alt="" />                    <p>When you're backed against the wall, break the god damn thing down.</p>                </li>                <li class="replies">                    <img src="/img/botimg.png" alt="" />                    <p>Excuses don't win championships.</p>                </li>                <li class="sent">                    <img src="/img/person1.png" alt="" />                    <p>Oh yeah, did Michael Jordan tell you that?</p>                </li>                <li class="replies">                    <img src="/img/botimg.png" alt="" />                    <p>No, I told him that.</p>                </li>            </ul>        </div>        <div class="message-input">            <div class="wrap">            <input type="text" placeholder="Write your message..." />            <i class="fa fa-paperclip attachment" aria-hidden="true"></i>            <button class="submit"><i class="fa fa-paper-plane" aria-hidden="true"></i></button>            </div>        </div>輔助功能:function newMessage() {    console.log("Inside newMessage");    message = $(".message-input input").val();    if($.trim(message) == '') {        return false;    }    $('<li class="sent"><img src="/img/person1.png" alt="" /><p>' + message + '</p></li>').appendTo($('.messages ul'));    $('.message-input input').val(null);    $(".messages").animate({ scrollTop: $(document).height() }, "fast");};提交點擊功能是:$('.submit').click(function() {  newMessage();});現在,每當我單擊“提交”按鈕時,“ Inside newMessage”消息就會不斷在JavaScript控制臺中記錄。
查看完整描述

1 回答

?
長風秋雁

TA貢獻1757條經驗 獲得超7個贊

清除Chrome瀏覽器的歷史記錄(特別是“ Cookie和其他數據”)后,它現在可以工作。


查看完整回答
反對 回復 2021-04-22
  • 1 回答
  • 0 關注
  • 146 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號