js实现微信聊天效果


Posted in Javascript onAugust 09, 2020

本文实例为大家分享了js实现微信聊天效果的具体代码,供大家参考,具体内容如下

<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <title>Title</title>
 <style>
  *{
   margin:0;
   padding:0;
  }
  .box{
   width: 250px;
   height: 400px;
   border: 1px solid #cccccc;
   float: left;
   margin-left: 200px;
   position: relative;
  }
  .fox{
   width: 250px;
   height: 400px;
   border: 1px solid #cccccc;
   float: left;
   margin-left: 200px;
   position: relative;
  }
  .box1{
   width: 250px;
   height: 20px;
   background: #cdcdcd;
   line-height: 20px ;
   text-align: center;
  }
  .fox1{
   width: 250px;
   height: 20px;
   background: #cdcdcd;
   line-height: 20px ;
   text-align: center;
  }
  .box3{
   width: 250px;
   height: 30px;
   bottom: 0px ;
   position: absolute;
  }
  .fox3{
   width: 250px;
   height: 30px;
   bottom: 0px ;
   position: absolute;
  }
  .input1{
   width: 200px;
   height: 28px;
  }
  .input2{
   width: 40px;
   height: 30px;
  }
  .input3{
   width: 200px;
   height: 28px;
  }
  .input4{
   width: 40px;
   height: 30px;
  }
  .text1{
   overflow: scroll;
   overflow-x: hidden;
   overflow-y: visible;
   height: 350px;
  }
  .text2{
   overflow: scroll;
   overflow-x: hidden;
   overflow-y: visible;
   height: 350px;
  }
 </style>
</head>
<body>
 <div class="box">
  <div class="box1">AAAAAAAA</div>
  <div class="text1"></div>
  <div class="box3">
   <input class="input1" type="text">
   <input class="input2" type="button" value="发送">
  </div>
 </div>
 <div class="fox">
  <div class="fox1">BBBBBBBB</div>
  <div class="text2"></div>
  <div class="fox3">
   <input class="input3" type="text">
   <input class="input4" type="button" value="发送">
  </div>
 </div>
 <script>
  var oIpt1=document.getElementsByClassName("input1")[0];
  var oIpt3=document.getElementsByClassName("input3")[0];
  var oIpt2=document.getElementsByClassName("input2")[0];
  var oIpt4=document.getElementsByClassName("input4")[0];
  var oText1=document.getElementsByClassName("text1")[0];
  var oText2=document.getElementsByClassName("text2")[0];

  oIpt2.onclick=function () {
   var newDate=new Date();
   var oHouer=newDate.getHours();
   var oMinutes=newDate.getMinutes();
   var oSecond=newDate.getSeconds();
   var oDiv1=document.createElement("div")
   var oDiv2=document.createElement("div")
   var oDiv3=document.createElement("div")
   var oDiv4=document.createElement("div")
   oDiv1.style.textAlign="right"
   oDiv2.style.textAlign="left"
   oDiv3.style.textAlign="center"
   oDiv4.style.textAlign="center"
   oText1.appendChild(oDiv3);
   oText1.appendChild(oDiv1);
   oText2.appendChild(oDiv4)
   oText2.appendChild(oDiv2);
   oDiv3.innerHTML=oHouer+"时"+oMinutes+"分"+oSecond+"秒"
   oDiv4.innerHTML=oHouer+"时"+oMinutes+"分"+oSecond+"秒"
   oDiv1.innerHTML=oIpt1.value;
   oDiv2.innerHTML=oIpt1.value;
   oIpt1.value=""
  }
  oIpt4.onclick=function () {
   var newDate=new Date();
   var oHouer=newDate.getHours();
   var oMinutes=newDate.getMinutes();
   var oSecond=newDate.getSeconds();
   var oDiv1=document.createElement("div")
   var oDiv2=document.createElement("div")
   var oDiv3=document.createElement("div")
   var oDiv4=document.createElement("div")
   oDiv1.style.textAlign="center"
   oDiv2.style.textAlign="center"
   oDiv3.style.textAlign="right"
   oDiv4.style.textAlign="left"
   oText2.appendChild(oDiv1);
   oText1.appendChild(oDiv2);
   oText2.appendChild(oDiv3);
   oText1.appendChild(oDiv4);
   oDiv1.innerHTML=oHouer+"时"+oMinutes+"分"+oSecond+"秒"
   oDiv2.innerHTML=oHouer+"时"+oMinutes+"分"+oSecond+"秒"
   oDiv3.innerHTML=oIpt3.value;
   oDiv4.innerHTML=oIpt3.value;
   oIpt3.value=""
  }
 </script>
</body>
</html>

为大家推荐现在关注度比较高的微信小程序教程一篇:《微信小程序开发教程》小编为大家精心整理的,希望喜欢。

希望本文所述对大家学习javascript程序设计有所帮助。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持三水点靠木。

Javascript 相关文章推荐
Firefox和IE浏览器兼容JS脚本写法小结
Jul 07 Javascript
使用CSS样式position:fixed水平滚动的方法
Feb 19 Javascript
JQuery中使用ajax传输超大数据的解决方法
Jul 14 Javascript
JavaScript原型及原型链终极详解
Jan 04 Javascript
jquery easyui dataGrid动态改变排序字段名的方法
Mar 02 Javascript
基于JavaScript实现类名的添加与移除
Apr 23 Javascript
js中的事件委托或是事件代理使用详解
Jun 23 Javascript
详解Vue学习笔记进阶篇之列表过渡及其他
Jul 17 Javascript
bootstrap fileinput插件实现预览上传照片功能
Jan 23 Javascript
vue项目webpack中Npm传递参数配置不同域名接口
Jun 15 Javascript
VUE在for循环里面根据内容值动态的加入class值的方法
Aug 12 Javascript
在Vue-cli里应用Vuex的state和mutations方法
Sep 16 Javascript
js实现盒子滚动动画效果
Aug 09 #Javascript
js仿京东放大镜效果
Aug 09 #Javascript
浅谈vue-props的default写不写有什么区别
Aug 09 #Javascript
js实现带有动画的返回顶部
Aug 09 #Javascript
Vue将props值实时传递 并可修改的操作
Aug 09 #Javascript
js实现轮播图效果 纯js实现图片自动切换
Aug 09 #Javascript
vue 子组件watch监听不到prop的解决
Aug 09 #Javascript
You might like
CodeIgniter实现从网站抓取图片并自动下载到文件夹里的方法
2015/06/17 PHP
在IIS下安装PHP扩展的方法(超简单)
2017/04/10 PHP
PHP与Web页面的交互示例详解二
2020/08/04 PHP
js面向对象设计用{}好还是function(){}好(构造函数)
2011/10/23 Javascript
jquery方法+js一般方法+js面向对象方法实现拖拽效果
2012/08/30 Javascript
如何让页面在打开时自动刷新一次让图片全部显示
2012/12/17 Javascript
png在IE6 下无法透明的解决方法汇总
2015/05/21 Javascript
原生js实现数字字母混合验证码的简单实例
2015/12/10 Javascript
js实现日历的简单算法
2017/01/24 Javascript
使用vue构建移动应用实战代码
2017/08/02 Javascript
使用angular-cli webpack创建多个包的方法
2018/10/16 Javascript
从零开始用webpack构建一个vue3.0项目工程的实现
2020/09/24 Javascript
Openlayers+EasyUI Tree动态实现图层控制
2020/09/28 Javascript
[06:38]DOTA2怒掀电竞风暴 2013Chinajoy
2013/07/27 DOTA
python根据日期返回星期几的方法
2015/07/06 Python
Python中序列的修改、散列与切片详解
2017/08/27 Python
Python实现的本地文件搜索功能示例【测试可用】
2018/05/30 Python
Python实现获取邮箱内容并解析的方法示例
2018/06/16 Python
django用户登录和注销的实现方法
2018/07/16 Python
解决PyCharm import torch包失败的问题
2018/10/13 Python
pandas数据集的端到端处理
2019/02/18 Python
简单了解python装饰器原理及使用方法
2019/12/18 Python
如何将你的应用迁移到Python3的三个步骤
2019/12/22 Python
Python3如何实现Win10桌面自动切换
2020/08/11 Python
关于css中margin的值和垂直外边距重叠问题
2020/10/27 HTML / CSS
HTML5 离线应用之打造零请求、无流量网站的解决方法
2013/04/25 HTML / CSS
Moda Operandi官网:美国奢侈品电商,海淘秀场T台同款
2020/05/26 全球购物
GWT都有什么特性
2016/12/02 面试题
庆七一活动方案
2014/01/25 职场文书
公司股权转让协议书
2014/04/12 职场文书
含预算的公司户外活动方案
2014/08/16 职场文书
教师竞聘上岗演讲稿
2014/09/03 职场文书
2014年幼儿园工作总结
2014/11/10 职场文书
2016春季幼儿园小班开学寄语
2015/12/03 职场文书
自制短波长线天线频率预选器 - 成功消除B2K之流的镜像
2021/04/22 无线电
Go语言基础函数基本用法及示例详解
2021/11/17 Golang