<meta charset="UTF-8"> <meta http-equiv="x-ua-compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>定时器</title> <script> var intervalId; function f() { var timeStr = (new Date()).toLocaleString(); var inputEle = document.getElementById("i1"); inputEle.value = timeStr; } function start() { f(); if (intervalId === undefined) { intervalId = setInterval(f, 1000); } } function end() { clearInterval(intervalId); intervalId = undefined; } </script> </head> <body> <input type="text" id="i1"> <input type="button" value="开始" id="start" onclick="start();"> <input type="button" value="结束" id="end" onclick="end();"> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>搜索框示例</title> </head> <body> <input id="d1" type="text" value="请输入关键字" onblur="blurs()" onfocus="focus()"> <script> function focus(){ var inputEle=document.getElementById("d1"); if (inputEle.value==="请输入关键字"){ inputEle.value=""; } } function blurs(){ var inputEle=document.getElementById("d1"); var val=inputEle.value; if(!val.trim()){ inputEle.value="请输入关键字"; } } </script> </body> </html>
<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <meta http-equiv="x-ua-compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>select联动</title> </head> <body> <select id="province"> <option>请选择省:</option> </select> <select id="city"> <option>请选择市:</option> </select> <script> data = {"河北省": ["廊坊", "邯郸"], "北京": ["朝阳区", "海淀区"], "山东": ["威海市", "烟台市"]}; var p = document.getElementById("province"); var c = document.getElementById("city"); for (var i in data) { var optionP = document.createElement("option"); optionP.innerHTML = i; p.appendChild(optionP); } p.onchange = function () { var pro = (this.options[this.selectedIndex]).innerHTML; var citys = data[pro]; // 清空option c.options.length = 0; for (var i=0;i<citys.length;i++) { var option_city = document.createElement("option"); option_city.innerHTML = citys[i]; c.appendChild(option_city); } } </script> </body> </html>
Linux 命令系列之 seq
Linux 提高操作效率之 tab 命令补全
Atlassian 系列软件安装(Crowd+JIRA+Confluence+Bitbucket+Bamboo)
代码质量管理 SonarQube 系列之 安装
kworkerds 挖矿木马简单分析及清理
shell 脚本常用调试方法
JVM 调优之 Eclipse 启动调优实战
基于 Njmon + InfluxDB + Grafana 实现性能指标实时可视监控
nmon 的下一代工具 njmon
- 最新文章
-
this、static关键字
变量、引用类型、构造方法
测试Promise与Async/await的基本使用
平衡Dom总结
深入现代浏览器(第二部分)
H5页游戏内存溢出问题
深入现代浏览器(第一部分)
GPU程序缓存(GPU Program Caching)
首次开发H5长图页总结
HTTP/2之旅 (翻译)
- 热门文章
-
CSS3动画总结学习(一)
从wireshake分析http和https的通信过程
React Native学习(五)—— 使用插件react-native-scrollable-tab-view
React Native学习(四)—— 写一个公用组件(头部)
React Native学习(三)—— 使用导航器Navigation跳转页面
React Native学习(二)—— 开始一个项目
React Native分享第三方遇到的问题
React Native学习——动画Animated(笔记)
React Native随笔——警告处理方法(持续更新)
React Native随笔——组件TextInput