一:列表之间数据移动

第一个列表里面有内容,第二个里面没有

实现功能:

  1. 点击左侧列表选中一项内容,点击按钮,复制到右侧
  2. 点击复制所有按钮,将左侧列表所有数据,复制到右侧

扩展功能:右侧列表实现去重复

<style type="text/css">
*{ margin:0px auto; padding:0px}
#wai{ width:500px; height:500px}
#left{ width:200px; height:500px; float:left}
#zhong{ width:100px; height:500px; float:left}
#right{ width:200px; height:500px; float:left}
</style>
</head><body>
<br />
<div id="wai"><div id="left"><select style="width:200px; height:300px" id="selleft" multiple="multiple"><option value="山东">山东</option><option value="淄博">淄博</option><option value="张店">张店</option></select></div><div id="zhong"><div style="margin-left:10px; margin-top:20px"><input style="width:60px; height:30px" type="button" value=">>" onclick="moveall()" /></div><div style="margin-left:10px; margin-top:30px"><input style="width:60px; height:30px" type="button" value=">" onclick="moveone()" /></div></div><div id="right"><select id="selright" multiple="multiple" style="width:200px; height:300px"></select></div>
</div><script type="text/javascript">function moveone()
{var left = document.getElementById("selleft");var right = document.getElementById("selright");var xz = left.value;var str = "<option value='"+xz+"'>"+xz+"</option>";//判断//alert(right.childNodes.item(0));var bs = 0;for(var i=0;i<right.childNodes.length;i++){if(right.childNodes.item(i).text==xz){bs = 1;}}if(bs==0){//追加
        right.innerHTML = right.innerHTML+str;}
}function moveall()
{var left = document.getElementById("selleft");var right = document.getElementById("selright");right.innerHTML = left.innerHTML;
}</script>

二:日期选择

 

实现当前年份的前5后5年的日期选择

实现功能:年份和月份页面加载完成使用JS循环添加,天数根据月份的变化动态添加改变

扩展功能:天数可以根据闰年平年变化

<body><select id="nian" onclick="biantian()"></select>年
<select id="yue" onclick="biantian()"></select>月
<select id="tian"></select>日<script type="text/javascript">
FillNian();
FillYue();
FillTian();
function FillNian()
{var b = new Date(); //获取当前时间var nian = parseInt(b.getFullYear());var str = "";for(var i=nian-5;i<nian+6;i++){str = str+"<option value='"+i+"'>"+i+"</option>";//添加<option>标签}document.getElementById("nian").innerHTML = str;}function FillYue()
{var str = "";for(var i=1;i<13;i++){str = str+"<option value='"+i+"'>"+i+"</option>";}document.getElementById("yue").innerHTML = str;
}function FillTian()
{var yue = document.getElementById("yue").value;var nian = document.getElementById("nian").value;var ts = 31;if(yue==4 || yue==6 || yue==9 || yue==11){ts=30;}if(yue==2){if((nian%4==0 && nian%100 != 0) || nian%400==0){ts = 29;}else{ts = 28;}}var str = "";for(var i=1;i<ts+1;i++){str = str+"<option value='"+i+"'>"+i+"</option>";}document.getElementById("tian").innerHTML = str;}function biantian()
{FillTian();
}
</script>
</body>

<style type="text/css">
*{ margin:0px auto; padding:0px}
#wai{ width:150px; height:300px;}
.list{ width:150px; height:40px; background-color:#66F; text-align:center; line-height:40px; vertical-align:middle; color:white; border:1px solid white;}
.list:hover{ cursor:pointer; background-color:#F33}
</style>
</head><body>
<br />
<div id="wai"><div class="list" onclick="xuan(this)" onmouseover="bian(this)" onmouseout="huifu()">张三</div><div class="list" onclick="xuan(this)" onmouseover="bian(this)" onmouseout="huifu()">李四</div><div class="list" onclick="xuan(this)" onmouseover="bian(this)" onmouseout="huifu()">王五</div>
</div></body><script type="text/javascript">function xuan(d)
{//清var list = document.getElementsByClassName("list");for(var i=0;i<list.length;i++){list[i].removeAttribute("bs");list[i].style.backgroundColor = "#66F";}//选
    d.setAttribute("bs",1);d.style.backgroundColor = "#F33";
}function bian(d)
{//清var list = document.getElementsByClassName("list");for(var i=0;i<list.length;i++){if(list[i].getAttribute("bs")!="1"){list[i].style.backgroundColor = "#66F";}}//选
    d.style.backgroundColor = "#F33";
}function huifu()
{var list = document.getElementsByClassName("list");for(var i=0;i<list.length;i++){if(list[i].getAttribute("bs")!="1"){list[i].style.backgroundColor = "#66F";}}
}</script>

四 滑动

<style type="text/css">
*{ margin:0px auto; padding:0px}
#wai{ width:100%; height:500px;}
#left{height:500px; background-color:#63C; float:left}
#right{ height:500px; background-color:#FC3; float:left}
#anniu{ width:50px; height:50px; background-color:#F30; position:absolute; top:225px; z-index:10; }
#anniu:hover{ cursor:pointer}
</style>
</head><body><div id="wai"><div id="left" style="width:200px"></div><div id="right" style="width:800px"></div>
</div><div id="anniu" style="left:175px" onclick="hua()"></div><script type="text/javascript">var id;function hua()
{id = window.setInterval("dong()",10);
}//滑动的方法,调一次滑动3px
function dong()
{//改蓝色的宽度 200pxvar zuo = document.getElementById("left");kd = zuo.style.width;if(parseInt(kd.substr(0,kd.length-2))>=800){window.clearInterval(id);return;}kd = parseInt(kd.substr(0,kd.length-2))+3;zuo.style.width = kd+"px";//改黄色的宽度var you = document.getElementById("right");ykd = you.style.width;ykd = parseInt(ykd.substr(0,ykd.length-2))-3;you.style.width = ykd+"px";//改红色的leftvar hong = document.getElementById("anniu");hleft = hong.style.left;hleft = parseInt(hleft.substr(0,hleft.length-2))+3;hong.style.left = hleft+"px";}</script>

五 随滚动条滚动改样式

<style type="text/css">
*{ margin:0px auto; padding:0px}
</style>
</head><body><div style="width:100%; height:100px; background-color:#63F"></div>
<div id="menu" style="width:100%; height:50px; background-color:#F36;"></div><input type="button" value="滚动" onclick="gun()" /><div style="width:100%; height:1000px; background-color:#FF6"></div></body>
<script type="text/javascript">window.onscroll = function(){var d = document.getElementById("menu");if(window.scrollY >= 100){d.style.position = "fixed";d.style.top = "0px";}else{d.style.position = "relative";}}function gun(){window.scrollTo(0,100);}</script>

六 图片的飞入飞出效果

<style type="text/css">
*{ margin:0px auto; padding:0px}
#tp{ width:900px; height:400px; overflow:hidden}
#img{ position:relative; }
</style>
</head><body><input type="button" value="飞入" onclick="feiru()" /><input type="button" value="飞出" onclick="feichu()" /><div id="tp"><img id="img" style="top:-400px; left:-900px" src="data:images/201610281326233959.jpg" width="900" height="400px" />
</div><script type="text/javascript">function feiru()
{fei();
}function fei()
{var img = document.getElementById("img");var topstr = img.style.top;var top = parseInt(topstr.substr(0,topstr.length-2))+4;img.style.top=top+"px";var leftstr = img.style.left;var left = parseInt(leftstr.substr(0,leftstr.length-2))+9;img.style.left = left+"px";if(top<-100){window.setTimeout("fei()",10);}else if(top>=-100 && top<0){window.setTimeout("fei()",30);}
}</script>

转载于:https://www.cnblogs.com/xingyue1988/p/6060942.html

HTMO DOM部分---小练习;列表之间移动、日期选择、好友选中、滑动效果、滚动条效果、飞入飞出效果。...相关推荐

  1. 微信小程序日历(酒店入住日期选择)

    微信小程序日历(酒店入住日期选择) wxml代码. <!-- 日历--> <!-- 引入wxs文件,用来在界面中使用函数 --> <wxs src="../.. ...

  2. Android所有小部件列表页面,伟大的Android时钟小部件列表,以帮助您了解时间 | MOS86...

    在上周的文章中,我提供了一些Android小部件的示例,可帮助用户监视和切换其设置(包括WiFi,电池,亮度,数据,GPS等).).在本周的Android小部件中,我将强调一些有用的时钟小部件,帮助您 ...

  3. vxe-input vue 日期选择组件带农历节日、小圆点提醒

    vxe-table vxe-input vue 日期选择组件带农历节日.小圆点提醒 默认的日期选择是没有节日信息的 可以通过 festival-method 方法自定义节日信息,接收一个对象,用于渲染 ...

  4. 初级练手的小项目列表

    分享从伯乐在线看到的一篇好文章  http://blog.jobbole.com/49762/?hmsr=toutiao.io&utm_medium=toutiao.io&utm_so ...

  5. 微信小程序列表实现文字内容超出隐藏并显示全文/收起按钮

    微信小程序列表实现文字内容超出隐藏并显示全文/收起按钮 针对这个功能,产品的需求如下 由于我们项目是教育类产品所以这里这个功能会用在发动态这里,就像微信朋友圈那样,我们叫班级圈. 用户发班级圈时,可以 ...

  6. 题目44:监护室每小时测量一次病人的血压,若收缩压在90 - 140之间并且舒张压在60 - 90之间(包含端点值)则称之为正常,现给出某病人若干次测量的血压值,计算病人保持正常血压的最长小时数。

    题目转载:http://python.wzms.com/s/1/37 题目描述: 监护室每小时测量一次病人的血压,若收缩压在90 - 140之间并且舒张压在60 - 90之间(包含端点值)则称之为正常 ...

  7. JS每日一题: 小程序页面之间如何通信?

    20190227 小程序页面之间如何通信? 首先将通信的模型列举出来, 分为以下几种 兄弟页面间通信 父路径页面向子路径页面通信 子路径页面向父路径页面通信 通信的方式 localStorage 本地 ...

  8. 如何查找两个列表之间的差异?

    1. 概述 查找相同数据类型的对象集合之间的差异是一项常见的编程任务.举个例子,假设我们有一份申请考试的学生名单和另一份通过考试的学生名单.这两张名单的区别会告诉我们那些没有通过考试的学生. 在Jav ...

  9. 小程序引用其他页面js_来聊聊小程序页面之间如何通信

    小程序页面之间如何通信? 首先将通信的模型列举出来, 分为以下几种 兄弟页面间通信 父路径页面向子路径页面通信 子路径页面向父路径页面通信 通信的方式 localStorage 本地存储 global ...

最新文章

  1. Android对话框-下篇-之设置activity为Dialog
  2. R语言tidyquant包的tq_transmute函数计算持有某只股票的天、月、周收益率、ggplot2使用条形图(bar plot)可视化股票月收益率数据条形图
  3. 推荐系统中的Bias/Debias大全
  4. rest_framework之解析器详解 05
  5. 如何记忆英语的成语、俗语等
  6. cxTreeList交换当前两个节点的的位置
  7. 信息传递(NOIP2015提高组Day1T2)
  8. 条件锁pthread_cond_t 的应用
  9. pandas 表操作
  10. linux 连接两个异构网,用cheops-ng管理Linux异构网络(图)
  11. 一、Nginx源码安装与yum安装
  12. # 遍历结构体_关于二叉树怎样建立和四种遍历方法你知道吗?
  13. 反比例函数matlab,matlab拟合指定反比例函数,在线等
  14. hashmap扩容_原创 | 我说我了解集合类,面试官竟然问我为啥HashMap的负载因子不设置成1!?
  15. mongoddb常用增删改查命令--推荐查询命令:
  16. 压摆率//电源抑制比//共模抑制比//直流增益、带宽和相位裕度//静态功耗和直流工作点
  17. 第一章 网络入门【仅参考】
  18. 一加和小米哪个好 一加用技术领先树立起品牌典范
  19. VRChat模型制作笔记
  20. python我的世界给予物品指令_我的世界给予物品指令大全 | 手游网游页游攻略大全...

热门文章

  1. 【微型计算机原理与接口技术】80X86微处理器发展与内部结构
  2. 软件设计师23-存储器系统02
  3. 港股打新之卖出策略(暗盘和首日)
  4. 阿里创业员工分享公司的BI选型之路!自研、开源的坑都踩过
  5. ras私钥c#转java_RSA密钥,JAVA与.NET之间转换
  6. 钢琴块2电脑版_风暴魔域2电脑版下载_电脑玩风暴魔域2模拟器_夜神安卓模拟器...
  7. php 完整redis类,PHP Redis类
  8. ad19pcb设置恢复默认_无需重装WINDOWS将计算机恢复到初始状态
  9. python下载包没用_Python下载各种功能包出问题
  10. Iranian ChamPions Cup 水题