发表日期: 2021-05-07 14:01:36 浏览次数:86
新安网站制作要多少钱【域名企业邮箱服务器注册申请办理】新安网络优化公司哪家好、新安软件开发外包价格、新安高端企业网站页面制作设计专业公司、新安微信公众号小程序购物支付搭建制作公司
新安县位于河南省洛阳市西部,地处北纬34°36′至北纬35°05′,东经111°53′至112°19′之间。北临黄河,与济源市及山西省垣曲县隔河相望;南与宜阳县接壤;西与渑池县及义马市为邻;东与洛阳市孟津区等 [27] 毗连。
新安历为十三朝古都洛阳畿地和西方门户,地扼函关古道,东连郑汴,西通长安,自古为中原要塞,军事重地。当代,陇海铁路及310国道、连霍高速公路横贯东西,更成为连接祖国西北、华东及华北间的重要通道。
新安不仅是河南省48个扩权县和50个对外开放重点县之一,也被誉为中西部地区发展潜力最大、最具活力的县市之一。 [1] 2020年7月29日,入选2019年重新确认国家卫生乡镇(县城)名单。 [2] 2020年11月,入选第六届全国文明城市 [3] 。
2020年11月,入选 “2020年中国工业百强县(市)”,排名第84位。 [4] 11月27日,被评为省级森林城市 [5] 。
2020年,新安县完成地区生产总值530亿元,同比增长4%,一般公共预算收入28.14亿元,同比增长5.9%;规模以上工业增加值同比增长4.7%;固定资产投资同比增长7.1%;社会消费品零售总额完成112.4亿元;城乡居民人均可支配收入分别达到38312元、18596元。 [29]
6.6 事件之onclick+定时器实例: 展示当前时间
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<input type="text" id="d1">
<button id="d2">开始</button>
<button id="d3">结束</button>
<script>
let t; // 3. 那么定义一个全局存储定时器的变量, 提供清除定时器能够访问到这个变量
let inputEle = document.getElementById('d1');
let startBtnEle = document.getElementById('d2');
let endBtnEle = document.getElementById('d3');
function showTime() {
let currentTime = new Date();
inputEle.value = currentTime.toLocaleString();
}
startBtnEle.onclick = function () {
if (!t) { // 2. 所以限制定时器只能开一个
t = setInterval(showTime, 1000); // 1. 每点击一次就会开设一个定时器 而t只指代最后一个
}
};
endBtnEle.onclick = function () {
clearInterval(t);
t = null; // 4. 清除完了定时器, 还应该将t重置为空, 如果不置位空, 下次点击!t布尔值位true
}
</script>
</body>
</html>
6.7 事件之onchange实例: 省市联动
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<select name="" id="d1"></select>
<select name="" id="d2"></select>
<script>
// onchange: 文本域变化事件. 应用场景:通常用于表单元素,当元素内容被改变时触发.
let proEle = document.getElementById('d1');
let cityEle = document.getElementById('d2');
let data = {
"河北省": ["廊坊", "邯郸"],
"北京": ["朝阳区", "海淀区"],
"山东": ["威海市", "烟台市"]
};
// 1. 为proEle和cityEle初始化提示option
proEle.innerHTML = "<option disabled selected>--请选择省--</option>";
cityEle.innerHTML = '<option disabled selected>--请选择市--</option>';
// 2. for循环取值获取省, 并将获取到的省添加到proEle内
for (let key in data) {
let optEle = document.createElement('option');
optEle.value = key;
optEle.innerText = key;
proEle.appendChild(optEle);
}
// 3. 当proEle被改变了自动触发绑定的onchange事件, 准备为cityEle添加对应的市区提供选择
proEle.onchange = function () {
cityEle.innerHTML = ''; // 关键: 一上来就清空市区optEle, 为了防止下面多次选择触发appendChild出现一直追加的情况.
let cityArray = data[proEle.value];
// 4. 循环所有的市 渲染到第二个select中
// // 方法一: 使用for循环. (提示: for循环取值争对数组取出来的是索引. 争对对象{}取出来的是key)
// for (let index in cityArray) {
// let optEle = document.createElement('option');
// optEle.value = cityArray[index];
// optEle.innerText = cityArray[index];
// cityEle.appendChild(optEle);
// }
// 方法二: 使用forEach
cityArray.forEach(function (city) {
let optEle = document.createElement('option');
optEle.value = city;
optEle.innerText = city;
cityEle.appendChild(optEle);
}, this);
};
</script>
</body>
</html>
7.练习
案例一:模态框
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
}
html, body {
height: 100%;
}
#bg {
height: 100%;
background-color: rgba(0, 0, 0, 0.3);
}
#content {
position: relative;
top: 150px;
width: 400px;
height: 200px;
line-height: 200px;
text-align: center;
color: red;
background-color: white;
margin: 0 auto;
}
#cancel {
position: absolute;
top: 0;
right: 0;
color: white;
width: 30px;
height: 30px;
line-height: 30px;
text-align: center;
background-color: red;
}
</style>
</head>
<body>
<input type="button" value="弹出模态框" id="btn">
<script>
var oBtn = document.getElementById('btn');
var oDiv = document.createElement('div');
var oP = document.createElement('p');
var oSpan = document.createElement('span');
oDiv.id = 'bg';
oP.id = 'content';
oSpan.id = 'cancel';
oP.innerHTML = '弹出模态框';
oSpan.innerHTML = 'X';
oDiv.appendChild(oP);
oP.appendChild(oSpan);
oBtn.onclick = function () {
this.parentNode.replaceChild(oDiv, this);
};
oSpan.onclick =function () {
oDiv.parentNode.replaceChild(oBtn,oDiv);
}
</script>
</body>
</html>
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
}
html,body {
height: 100%;
}
#bg {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0,0,0,0.3);
display: none;
}
#content {
position: absolute;
top: 100px;
left: 50%;
margin-left: -150px;
background-color: white;
width: 300px;
height: 200px;
}
#content p:nth-child(3) {
position: absolute;
top: 100px;
}
</style>
</head>
<body>
<input type="button" value="弹出" id="btn">
<div id="bg">
<div id="content">
<p>
<label for="inp-username">用户名: </label><input type="text" name="username" id="inp-username">
</p>
<p>
<label for="inp-password">密码: </label><input type="text" name="username" id="inp-password">
</p>
<p>
<input type="button" value="提交" >
<input type="button" value="取消" id="cancel">
</p>
</div>
</div>
<script>
var oBtn = document.getElementById('btn');
var oBg = document.getElementById('bg');
var oInpUsername=document.getElementById('inp-username');
var oInpPwd=document.getElementById('inp-password');
var oInp=document.getElementById('cancel');
oBtn.onclick=function () {
oBg.style.display='block';
}
oInp.onclick=function () {
oInpUsername.value='';
oInpPwd.value='';
oBg.style.display='none'
}
</script>
</body>
</html>
案例二:点击有惊喜
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
}
.box {
width: 200px;
height: 200px;
background: red;
text-align: center;
color: white;
line-height: 200px;
font-size: 23px;
font-weight: bold;
margin: 20px auto;
}
</style>
</head>
<body>
<div>点击有惊喜!!!</div>
<script>
var oBox = document.getElementsByClassName('box')[0];
//初始化点击的次数。通过次数的增加来改变DOM的样式
var a = 0;
oBox.onclick = function () {
a++;
console.log(a % 4);
if (a % 4 === 1) {
this.style.background = 'green';
this.innerText = '继续点击哦!!!';
} else if (a % 4 == 2) {
this.style.background = 'blue';
this.innerText = '骗你的,傻逼';
} else if (a % 4 == 3) {
this.style.background = 'transparent';
this.innerText = '';
} else {
this.style.background = 'red';
this.innerText = '点击有惊喜!!!';
}
}
</script>
</body>
</html>
案例三:简易评论板
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
}
#comment {
background-color: #b0b0b0;
width: 500px;
}
#comment ul li {
list-style: none;
background-color: wheat;
border: 1px dashed #000;
margin: 0px 10px 10px;
word-break: break-all;
word-wrap: break-word;
}
</style>
</head>
<body>
<div id="comment">
<p>评论内容:</p>
</div>
<div id="box">
<p>留言内容:</p>
<textarea name="" id="content" cols="30" rows="10"></textarea>
<p>
<input type="button" value="提交" id="btn">
<input type="button" value="统计" id="calculate">
</p>
</div>
<script>
var comment = document.getElementById('comment');
var box = document.getElementById('box');
var submit = document.getElementById('submit');
var content = document.getElementById('content');
var btn = document.getElementById('btn');
var calculate=document.getElementById('calculate');
var ul = document.createElement('ul');
comment.appendChild(ul);
var count=0;
btn.onclick = function () {
var val = content.value;
if (val.length != 0) {
var date = new Date();
var subTime = date.toLocaleString();
var li = document.createElement('li');
var p1 = document.createElement('h3');
var p2 = document.createElement('p');
var spans = document.getElementsByClassName('del');
count=spans.length+1;
p1.innerHTML = '#'+'<span>'+count+'</span>'+'楼'+' '+subTime + '<span> 删除</span>';
p2.innerHTML = val;
li.appendChild(p1);
li.appendChild(p2);
ul.appendChild(li);
content.value = '';
}
function aa() {
var spans = document.getElementsByClassName('del');
for (var i = 0; i < spans.length; i++) {
spans[i].onclick=function (currentIndex) {
function bb() {
ul.removeChild(this.parentNode.parentNode);
count--;
var ss=document.getElementsByClassName('num');
for (var j=currentIndex;j<ss.length;j++){
ss[j].innerHTML=parseInt(ss[j].innerHTML)-1;
}
aa();
}
return bb;
}(i);
}
}
aa()
};
calculate.onclick = function () {
alert('一共发布了'+count+'条评论');
}
</script>
</body>
</html>
案例四:选项卡
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
}
.tab {
width: 480px;
height: 200px;
border: 1px solid red;
margin: 0 auto;
}
ul li {
list-style: none;
width: 160px;
height: 60px;
line-height: 60px;
text-align: center;
background-color: #b0b0b0;
float: left;
}
li.active {
background-color: #55BBBB;
}
p {
display: none;
height: 200px;
text-align: center;
line-height: 200px;
background-color: white;
}
p.active {
display: block;
}
</style>
</head>
<body>
<div>
<ul>
<li>首页</li>
<li>新闻</li>
<li>图片</li>
</ul>
<p>首页内容</p>
<p>新闻内容</p>
<p>图片内容</p>
</div>
<script>
var aLi=document.getElementsByTagName('li');
var aP=document.getElementsByTagName('p');
for (var i=0;i<aLi.length;i++){
aLi[i].index=i;
aLi[i].onclick=function () {
for (var j=0;j<aLi.length;j++){
aLi[j].className='';
aP[j].className='';
}
this.className='active';
aP[this.index].className='active';
}
}
</script>
</body>
</html>
案例五:仿淘宝搜索框
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
}
#search {
position: relative;
}
input {
outline: none;
display: block;
border: 2px solid #f2a83c;
border-radius: 10px;
width: 490px;
height: 50px;
margin-top: 20px;
}
label {
position: absolute;
top: 20px;
left: 10px;
font-size: 8px;
color: gray;
}
</style>
</head>
<body>
<div id="search">
<input type="text" id="text">
<label for="text" id="msg">老男孩上海校区</label>
</div>
<script>
var txt = document.getElementById('text');
var msg = document.getElementById('msg');
//检测用户表单输入的时候
txt.oninput = function () {
//控制元素显示隐藏
if (this.value == '') {
msg.style.display = 'block';
} else {
msg.style.display = 'none';
}
}
</script>
</body>
</html>
案例六:获取当前时间
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script>
setInterval(function () {
var date = new Date();
var y = date.getFullYear();
var m = date.getMonth();
var d = date.getDate();
var h = date.getHours();
var min = date.getMinutes();
var s = date.getSeconds();
//今天是2018年2月23日 8:23:09
document.body.innerHTML = "今天是" + y + '年' + num(m + 1) + "月" + num(d) + "日" + num(h) + ":" + num(min) + ":" + num(s)
}, 1000)
function num(n) {
if (n < 10) {
return "0" + n;
}
return n
}
</script>
</body>
</html>
案例七:匀速运动
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
* {
padding: 0;
margin: 0;
}
.box {
width: 200px;
height: 200px;
background-color: #FF0000;
position: absolute;
top: 50px;
left: 0px;
}
</style>
</head>
<body>
<div id="wrap">
<button id="btn1">前进</button>
<button id="btn2">后退</button>
<div id="box1">
</div>
</div>
<script>
var btn1 = document.getElementById('btn1');
var btn2 = document.getElementById('btn2');
var box1 = document.getElementById('box1')
var count = 0;
var time1 = null;
var time2 = null;
btn1.onclick = function () {
clearInterval(time2);
time1 = setInterval(function () {
count += 10;
if (count > 1000) {
box1.style.left = '1000px';
box1.style.borderRadius = '50%';
clearInterval(time1);
} else {
box1.style.left = count + 'px';
box1.style.borderRadius = count / 2000 * 100 + '%';
}
}, 10)
};
btn2.onclick = function () {
clearInterval(time1);
time2 = setInterval(function () {
count -= 10;
if (count <= 0) {
box1.style.left = '0px';
box1.style.borderRadius = '';
clearInterval(time2);
} else {
box1.style.left = count + 'px';
box1.style.borderRadius = count / 2000 * 100 + '%';
;
}
}, 10)
}
</script>
</body>
</html>
案例八:5s后关闭广告
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
* {
padding: 0;
margin: 0;
}
img {
position: fixed;
width: 300px;
}
ul {
list-style: none;
}
#left {
left: 0;
}
#right {
right: 0;
}
ul li {
font-size: 25px;
}
</style>
</head>
<body>
<img src="images/1.jpg" id="left">
<img src="images/1.jpg" id="right">
<ul>
<li>屠龙宝刀,点击就送</li>
<li>屠龙宝刀,点击就送</li>
<li>屠龙宝刀,点击就送</li>
<li>屠龙宝刀,点击就送</li>
<li>屠龙宝刀,点击就送</li>
<li>屠龙宝刀,点击就送</li>
<li>屠龙宝刀,点击就送</li>
<li>屠龙宝刀,点击就送</li>
<li>屠龙宝刀,点击就送</li>
<li>屠龙宝刀,点击就送</li>
<li>屠龙宝刀,点击就送</li>
<li>屠龙宝刀,点击就送</li>
<li>屠龙宝刀,点击就送</li>
<li>屠龙宝刀,点击就送</li>
<li>屠龙宝刀,点击就送</li>
<li>屠龙宝刀,点击就送</li>
<li>屠龙宝刀,点击就送</li>
<li>屠龙宝刀,点击就送</li>
<li>屠龙宝刀,点击就送</li>
<li>屠龙宝刀,点击就送</li>
<li>屠龙宝刀,点击就送</li>
<li>屠龙宝刀,点击就送</li>
<li>屠龙宝刀,点击就送</li>
<li>屠龙宝刀,点击就送</li>
<li>屠龙宝刀,点击就送</li>
<li>屠龙宝刀,点击就送</li>
<li>屠龙宝刀,点击就送</li>
<li>屠龙宝刀,点击就送</li>
<li>屠龙宝刀,点击就送</li>
<li>屠龙宝刀,点击就送</li>
</ul>
<script>
window.onload = function () {
var left = document.getElementById('left');
var right = document.getElementById('right');
setTimeout(function () {
left.style.display = 'none';
right.style.display = 'none';
}, 5000)
}
</script>
</body>
</html>
案例九:小米滚动
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
* {
padding: 0;
margin: 0;
}
.wrap {
width: 512px;
height: 400px;
border: 3px solid #808080;
position: relative;
overflow: hidden;
margin: 100px auto;
}
.wrap span {
width: 100%;
height: 200px;
position: absolute;
background-color: transparent;
border: 1px solid #000;
}
.up {
top: 0;
}
.down {
bottom: 0;
}
img {
position: absolute;
top: 0;
left: 0;
height: 200px;
}
</style>
</head>
<body>
<div id="box">
<img src="images/mi.png" id="xiaomi">
<span id="picUp">11111</span>
<span id="picDown">22222</span>
</div>
<script>
var up = document.getElementById('picUp');
var down = document.getElementById('picDown');
var img = document.getElementById('xiaomi');
var count = 0;
var time = null;
//鼠标移入的时候吧
up.onmouseover = function () {
//不管怎样 上来先清定时器
clearInterval(time);
time = setInterval(function () {
count -= 3;
count >= -1070 ? img.style.top = count + 'px' : clearInterval(time);
}, 30)
};
down.onmouseover = function () {
clearInterval(time);
time = setInterval(function () {
count += 1;
count < 0 ? img.style.top = count + 'px' : clearInterval(time);
}, 30)
}
</script>
</body>
</html>
案例十:无缝轮播
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
* {
padding: 0;
margin: 0;
}
ul {
list-style: none;
}
.box {
width: 600px;
height: 700px;
margin: 50px auto;
overflow: hidden;
position: relative;
border: 1px solid #000;
}
ul li {
float: left;
}
.box ul {
width: 500%;
position: absolute;
top: 0;
left: 0;
}
img {
width: 600px;
}
</style>
</head>
<body>
<div>
<ul>
<li><img src="https://images2018.cnblogs.com/blog/1036857/201805/1036857-20180516225816920-580320384.jpg"/></li>
<li><img src="https://images2018.cnblogs.com/blog/1036857/201805/1036857-20180516225809591-1990809146.jpg"/></li>
<li><img src="https://images2018.cnblogs.com/blog/1036857/201805/1036857-20180516225724530-539090864.jpg"/></li>
<li><img src="https://images2018.cnblogs.com/blog/1036857/201805/1036857-20180516225751362-1832630751.jpg"/></li>
<li><img src="https://images2018.cnblogs.com/blog/1036857/201805/1036857-20180516225816920-580320384.jpg"/></li>
</ul>
</div>
<script>
var box = document.getElementsByClassName('box')[0];
var ul = box.children[0];
var num = 0;
var timer = null;
timer = setInterval(autoPlay, 3);
//函数的声明
function autoPlay() {
num--;
num <= -2400? num = 0: num;
ul.style.left = num + 'px'
}
//鼠标移动上去
box.onmouseover = function () {
clearInterval(timer)
};
box.onmouseout = function () {
timer = setInterval(autoPlay, 3);
}
</script>
</body>
</html>
案例十一:用户名和密码校验
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
span {
background-color: red;
}
</style>
</head>
<body>
<form>
<p>
<input type="text" name="username">
<span></span>
</p>
<p>
<input type="password" name="password">
<span></span>
</p>
<p>
<input type="button" value="提交" id="btn">
</p>
</form>
<script>
var isOk1=false
var reg1=new RegExp('(?!^[0-9]+$)(?!^[a-zA-Z]+$)^[0-9A-Za-z]{4}$')
var inp1 = document.getElementsByName("username")[0]
inp1.onblur=function () {
var res=reg1.test(this.value)
this.style.border="1px solid red"
if (!res) {
this.nextElementSibling.innerText="用户名必须由4位字母和数字组成"
setTimeout(function () {
inp1.nextElementSibling.innerText=""
inp1.value=""
},3000)
}else {
this.style.border="1px solid green"
isOk1=true
}
}
var isOk2=false
var reg2=new RegExp('(?!^[0-9]+$)(?!^[a-zA-Z]+$)^[0-9A-Za-z]{6}$')
var inp2 = document.getElementsByName("password")[0]
inp2.onblur=function () {
var res=reg2.test(this.value)
this.style.border="1px solid red"
if (!res) {
this.nextElementSibling.innerText="密码必须由6位字母和数字组成"
setTimeout(function () {
inp2.nextElementSibling.innerText=""
inp2.value=""
},3000)
}else {
this.style.border="1px solid green"
isOk2=true
}
}
var btn=document.getElementById("btn")
btn.onclick=function () {
if(isOk1 && isOk2) {
alert("提交成功")
}else {
alert("请重新填写")
}
}
</script>
</body>
</html>
四、总结:
/*
查找标签:
直接查找:
id查找 document.getElementById() 返回对象
类名查找 document.getElementsByClassName() 返回数组对象
标签名查找 document.getElementByTagName() 返回数组对象
间接查找:
查找父标签: 没有父标签则返回null
divEle.parentElement
查找所有子标签: 返回数组对象, 通过索引取值获取对应子标签
divEle.children
查找第一个子标签:
divEle.firstElementChild
divEle.children[0]
查找最后一个子标签:
divEle.lastElementChild
divEle.children[divEle.children.length-1]
查找同级别上一个:
divEle.nextElementSibling
查找同级别下一个:
divEle.previousElementSibling
节点操作:
创建标签:
let aEle = document.createElement('a');
添加属性:
添加内置: aEle.alt='';
添加内置+自定义: aEle.setAttribute('username', 'egon');
拓展: getAttribute('username') removeAttribute('username')
文本操作:
获取所有文本: aEle.innerText;
获取所有文本+标签: aEle.innerHTML;
添加文本: aEle.innerText='xxx';
添加文本+标签: aEle.innerHTML='<h1>xxx</h1>;
追加标签:
let divEle = document.getElementById('d1');
divEle.appendChild(aEle);
拓展: removeChild(aEle) replaceChild(src, dst)
插入标签:
let pEle = divEle.children[0];
divEle.inertBefore(aEle, pEle)
获取值操作:
获取非文件: inputEle.value
获取文件:
获取文件本次上传路径: inputEle.value
获取文件对象集合: inputEle.files 返回格式{0: 文件对象, 1: 文件对象1}
获取某一个文件对象: inputEle.files[0]
拓展: 值清空
inputEle.value=''
class, css操作:
class操作:
获取所有类属性: divEle.classList 返回数组对象
获取某一个类属性: divEle.classList[0] 返回数组对象中按照索引取值的类名
对获取到的所有类属性进行追加: divEle.classList.add('bg_red')
对获取到的所有类属性进行删除: divEle.classList.remove('bg_red')
对获取到的所有类属性判断是否存在某个类: divEle.classList.contains('bg_red') 返回布尔值
对获取到的所有类属性判断有则删除,无则添加: divEle.classList.toggle('bg_red') 之前有布尔值为true, 执行了以后删除了它, 布尔值就是false
css操作: 统一style起手, 将css中的横杆换成驼峰体
divEle.style.backgroundColor = 'red';
divEle.style.fontSize = '28px';
事件: 满足某种条件自动触发的功能
导入js的2种方式:
head中绑定预加载事件window.onload. 预加载无法执行以下的绑定事件的第一种方式. 且不能多次声明, 多次绑定, 下面会覆盖上面
body中底部
绑定事件的2种方式:
标签中定义属性οnclick='func()'
通过DOM操作获取标签对象, 再通过标签对象绑定事件. 例如: aEle.onclick = function () {}
onclick 鼠标单击事件.
实例1: 开关灯. 主要利用nodeEle.classList.toggle实现
实例2: 展示当前时间. 主要利用创建时间对象new Date() + 循环定时器实现
onfocus 获得焦点时触发事件 + onblur 失去焦点时触发事件.
实例: input框的焦点获取与失去. 主要利用inputEle.value实现
onchange 文本域变化事件
实例: 省市联动. 主要利用节点操(创建标签, 为标签添加属性, 为标签添加文本内容, 找到需要添加的位置添加)
常用事件总结:
onclick 鼠标单击
ondblclick 双击后激活事件
onfocus 获得焦点时触发
onblur 失去焦点时触发 应用场景:用于表单验证,用户离开某个输入框时,代表已经输入完了,我们可以对它进行验证.
onchange 域的内容被改变。 应用场景:通常用于表单元素,当元素内容被改变时触发.(select联动)
onkeydown 某个键盘按键被按下。 应用场景: 当用户在最后一个输入框按下回车按键时,表单提交
onkeypress 某个键盘按键被按下并松开。
onkeyup 某个键盘按键被松开。
onload 载入网页时
onmousedown 鼠标按钮被按下。
onmousemove 鼠标被移动。
onmouseout 鼠标从某元素移开。
onmouseover 鼠标移到某元素之上。
onselect 在文本框中的文本被选中时发生。
onsubmit 确认按钮被点击,使用的对象是form。
*/
新安网站制作要多少钱【域名企业邮箱服务器注册申请办理】新安网络优化公司哪家好、新安软件开发外包价格、新安高端企业网站页面制作设计专业公司、新安微信公众号小程序购物支付搭建制作公司
备案号: 苏ICP备11067224号
CopyRight © 2011 书生商友信息科技 All Right Reserved
24小时服务热线:品茶服务联系十Q/Q:【3775586952】 E-MAIL:1120768800@qq.com QQ:1120768800
网址: https://www.768800.com 网站建设:上往建站
关键词: 网站建设| 域名邮箱| 服务器空间| 网站推广| 上往建站| 网站制作| 网站设计| 域名注册| 网络营销| 网站维护|
企业邮箱| 虚拟主机| 网络建站| 网站服务| 网页设计| 网店美工设计| 网站定制| 企业建站| 网站设计制作| 网页制作公司|
400电话办理| 书生商友软件| 葬花网| 调温纤维| 海洋馆运营维护| 北京保安公司| 殡仪馆服务| 殡葬服务| 昌平殡葬| 朝阳殡葬|
欢迎您免费咨询,请填写以下信息,我们收到后会尽快与您联系
服务热线:品茶服务联系十Q/Q:【3775586952】