又是一波福利!原聲的js實作了一個簡單的微信聊天功能,拿去研究吧,不要錢!更多免費好玩的源碼盡在PHP中文網
#
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>微信聊天</title> <link rel="stylesheet" type="text/css" href="css/style.css" /> <style> *{ margin: 0; } .top{ width: 310px; padding: 10px 20px; background-color: gray; border-top-left-radius: 5px; border-top-right-radius: 5px; font-size: 18px; font-weight: bold;0 color: white; } .content{ background-color: white; } select{ border: 2px solid gray; background: white; width: 350px; height: 470px; padding: 10px; } .send{ width: 310px; padding: 10px 20px; background-color: gray; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; } .chat{ } .box{ float: left; margin: 20px 120px; } body{ width: 100%; background-image: url(../img/bg.jpg); } .outer{ width: 90%; margin: 10px auto; } .sText{ width: 220px; height: 25px; border-radius: 5px; font-size: 15px; } .btn{ width: 65px; height: 30px; border-radius: 5px; float: right; text-align: center; font-size: 18px; color: white; background-color: limegreen; } option{ font-size: 15px; max-width: 325px; height: auto; border: 0.5px solid gainsboro; border-radius: 8px; padding: 10px; margin: 10px; background-color: greenyellow; margin-left: 158px; margin-top: 10px; margin-bottom: 10px; max-width: 200px; } </style> <script type="text/javascript" src="js/my.js" ></script> <script > window.onload =function () { function g(id) { return document.getElementById(id); } g('leftSendBtn').addEventListener("click",leftSendB); g('rightSendBtn').addEventListener("click",rightSendB); } function leftSendB() { function g(id) { return document.getElementById(id); } var text = document.getElementById("leftText").value; if(text.trim()!=''){ var leftContent = document.getElementById("leftContent"); var rightContent = g("rightContent"); var option = document.createElement('option'); var len = text.length; option.style.width = len * 15 + len*2 + "px"; option.style.marginLeft = 350 - (len * 15 + len*2) - 72 +"px"; option.innerHTML = text; leftContent.appendChild(option); var option1 = document.createElement("option"); option1.innerHTML = text; option1.style.backgroundColor = "white"; option1.style.marginLeft = "10px"; option1.style.width = len * 15 + len*2 + "px"; rightContent.appendChild(option1); document.getElementById("leftText").value = ""; } } function rightSendB() { function g(id) { return document.getElementById(id); } var text = g("rightText").value; if(text.trim()!='') { var leftContent = document.getElementById("leftContent"); var rightContent = g("rightContent"); var option = document.createElement('option'); var len = text.length; option.style.width = len * 15 + len*2 + "px"; option.style.marginLeft = 350 - (len * 15 + len*2) - 72 +"px"; option.innerHTML = text; rightContent.appendChild(option); var option1 = document.createElement("option"); option1.innerHTML = text; option1.style.backgroundColor = "white"; option1.style.marginLeft = "10px"; option1.style.width = len * 15 + len*2 + "px"; leftContent.appendChild(option1); g("rightText").value = ""; } } </script> </head> <body> <p class="outer"> <p class="box"> <p class="chat"> <p class="top"> <span class="">PHP中文网-朱老师</span> </p> <p class="content"> <select multiple="multiple" id="leftContent"> </select> </p> <p class="send"> <input type="text" id="leftText" class="sText"/> <input type="button" id="leftSendBtn" class="btn" value="发送"/> </p> </p> </p> <p class="box"> <p class="chat"> <p class="top"> <span class="">PHP中文网-lge</span> </p> <p class="content"> <select multiple="multiple" id="rightContent"> </select> </p> <p class="send"> <input type="text" id="rightText" class="sText"/> <input type="button" id="rightSendBtn" class="btn" value="发送"/> </p> </p> </p> </p> </body> </html>
免費拿去研究吧!更多好的源碼盡在PHP中文網,關注我們給你好看~
相關推薦:
以上是js原聲實現簡單的微信聊天功能的詳細內容。更多資訊請關注PHP中文網其他相關文章!

htmltagsareessentialforsenteringwebpages,增強輔助性,seo,and Performance.1)他們areAnclosedInanglebracketSandInpairStocrateAteAhierArchical.2)samantictagsictagsagtagslikleicereperreveuseerexperienceandseo.3)

self-closingtagsinhtmlandxmlaretagsthatclosethem hexptneedneedingAseparateClosingTag,SightifyingmarkupStrupupStrupureAndenHancingCodingsigy.1)shemesessientInsentialInxmlforelementswithcontentsswithcontent content content content content content content content content contentcontent,確保wellwell-formedDocuments.2)Inhtmlible5,inhtmlibut forfix

要構建一個功能強大且用戶體驗良好的網站,僅靠HTML是不夠的,還需要以下技術:JavaScript賦予網頁動態和交互性,通過操作DOM實現實時變化。 CSS負責網頁的樣式和佈局,提升美觀度和用戶體驗。現代框架和庫如React、Vue.js和Angular,提高開發效率和代碼組織結構。

布爾屬性是HTML中的特殊屬性,不需要值即可激活。 1.布爾屬性通過存在與否控制元素行為,如disabled禁用輸入框。 2.它們的工作原理是瀏覽器解析時根據屬性的存在改變元素行為。 3.基本用法是直接添加屬性,高級用法可通過JavaScript動態控制。 4.常見錯誤是誤以為需要設置值,正確寫法應簡潔。 5.最佳實踐是保持代碼簡潔,合理使用布爾屬性以優化網頁性能和用戶體驗。

HTML代碼可以通過在線驗證器、集成工具和自動化流程來確保其清潔度。 1)使用W3CMarkupValidationService在線驗證HTML代碼。 2)在VisualStudioCode中安裝並配置HTMLHint擴展進行實時驗證。 3)利用HTMLTidy在構建流程中自動驗證和清理HTML文件。

HTML、CSS和JavaScript是構建現代網頁的核心技術:1.HTML定義網頁結構,2.CSS負責網頁外觀,3.JavaScript提供網頁動態和交互性,它們共同作用,打造出用戶體驗良好的網站。

HTML的功能是定義網頁的結構和內容,其目的在於提供一種標準化的方式來展示信息。 1)HTML通過標籤和屬性組織網頁的各個部分,如標題和段落。 2)它支持內容與表現分離,提升維護效率。 3)HTML具有可擴展性,允許自定義標籤增強SEO。

HTML的未來趨勢是語義化和Web組件,CSS的未來趨勢是CSS-in-JS和CSSHoudini,JavaScript的未來趨勢是WebAssembly和Serverless。 1.HTML的語義化提高可訪問性和SEO效果,Web組件提升開發效率但需注意瀏覽器兼容性。 2.CSS-in-JS增強樣式管理靈活性但可能增大文件體積,CSSHoudini允許直接操作CSS渲染。 3.WebAssembly優化瀏覽器應用性能但學習曲線陡,Serverless簡化開發但需優化冷啟動問題。


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

EditPlus 中文破解版
體積小,語法高亮,不支援程式碼提示功能

SublimeText3漢化版
中文版,非常好用

MinGW - Minimalist GNU for Windows
這個專案正在遷移到osdn.net/projects/mingw的過程中,你可以繼續在那裡關注我們。 MinGW:GNU編譯器集合(GCC)的本機Windows移植版本,可自由分發的導入函式庫和用於建置本機Windows應用程式的頭檔;包括對MSVC執行時間的擴展,以支援C99功能。 MinGW的所有軟體都可以在64位元Windows平台上運作。

mPDF
mPDF是一個PHP庫,可以從UTF-8編碼的HTML產生PDF檔案。原作者Ian Back編寫mPDF以從他的網站上「即時」輸出PDF文件,並處理不同的語言。與原始腳本如HTML2FPDF相比,它的速度較慢,並且在使用Unicode字體時產生的檔案較大,但支援CSS樣式等,並進行了大量增強。支援幾乎所有語言,包括RTL(阿拉伯語和希伯來語)和CJK(中日韓)。支援嵌套的區塊級元素(如P、DIV),

DVWA
Damn Vulnerable Web App (DVWA) 是一個PHP/MySQL的Web應用程序,非常容易受到攻擊。它的主要目標是成為安全專業人員在合法環境中測試自己的技能和工具的輔助工具,幫助Web開發人員更好地理解保護網路應用程式的過程,並幫助教師/學生在課堂環境中教授/學習Web應用程式安全性。 DVWA的目標是透過簡單直接的介面練習一些最常見的Web漏洞,難度各不相同。請注意,該軟體中