WordPress

推荐列表 站点导航

当前位置:首页 > 建站教程 > WordPress >

js实现滑动滑块验证登录的具体代码

来源:网络整理  作者:  发布时间:2020-12-18 01:24
本文实例为大家分享了js实现滑动滑块验证登录的具体代码,供大家参考,具体内容如下1.html代码divclass=box!--滑...

4.结束,松开按钮,按钮不可再次拖动

if(flag)return;

btn.onmousedown=null;

bg.style.width=moveX+"px";//背景

3.js事件

.bg{

width: 100%;

window.onload=function(){

}

var btn=document.querySelector(".btn");

//原生写法

1.按钮按下并移动

btn.onmousemove=null;

color: black;

position: absolute;

position: relative;

if(flag)return;

bg.style.width=0;//背景

1)

if(moveX>-2){

height: 100%;

this.style.left=moveX+"px";//将移动值赋值给滑块

js实现滑动滑块验证登录的具体代码 (https://www.wpmee.com/) javascript教程 第2张

// var box=$(".box"),btn=$(".btn").....;

// };

/*-webkit-margin-before: 1em;

btn.onmousemove=function(e){//拖动

2.事件状态:event对象(鼠标位置)event.clientX获得与X轴的距离

text.style.color="white";

}

1.html代码

或者使用封装选择器

//获取方法集合,可直接通过id, 类, 类型, 属性, 属性值等来选取元素(返回此名字的第一个)。

//移动范围

btn.onmousedown=function(e){//按下

js实现滑动滑块验证登录的具体代码 (https://www.wpmee.com/) javascript教程 第1张

flag=true;

}  

<!--背景-->

需要根据层级设置z-index保证滑动的正常使用

var text=document.querySelector(".text");

position: absolute;

js实现滑动滑块验证登录的具体代码 (https://www.wpmee.com/) javascript教程 第3张

left: 20px;

//事件清除

var bg=document.querySelector(".bg");

<a href="#" ><div>>></div></a>

text.style.color="white";

根据移动的值:判断按钮是否可以正常移动,判断按钮是否已经完成验证

<div>

bg.style.width=moveX+"px";//背景

flag=true;

line-height: 34px;

var box=document.querySelector(".box");

background-color: yellowgreen;

var bg=document.querySelector(".bg");

//封装选择器

分析使用过程:按住滑块并拖动可以移动,中途松开滑块返回起始位置,拖动至最后滑块不动

this.style.left=0;//将移动值赋值给滑块

top: 0;

// var e=event||window.event;

background: #e8e8e8;

border-radius: 4px;

border: 1px solid #ccc;

width: 40px;

}

z-index: 1;

2.css样式

btn.onmousedown=null;

<p>拖动滑块验证</p>

分析动作:

3.松开按钮回到原处

}

var downX=e.clientX; //按下后对x轴的距离

this.style.left=moveX+"px";//将移动值赋值给滑块

btn.onmousemove=null;

<!--滑块-->

<!--文字-->

background-color: #fff;

text-align: center;

//事件清除

最大的盒子相对定位,其他内部内容绝对定位

回到原处清除拖动

bg.style.width=0;//背景

btn.onmouseup=function(){

//移动范围

var flag=false;

btn.onmousemove=function(e){

text-align: center;

.btn{

</div>  

height: 34px;

if(moveX>=(box.offsetWidth-btn.offsetWidth)){//包含原始宽度内边距边框,不包含外边框

4)松开按钮

按下后获得与x轴的距离

//事件清除

.text{

var text=document.querySelector(".text");  

margin: 0;

//document.querySelector(".btn").onmousedown=function(event){//event事件状态

<div></div>

样式

}

//按下onmousedown 拖动onmousemove

var moveX=e.clientX-downX; //拖动后与x轴距离减去初始值距离,移动值

if(moveX>=(box.offsetWidth-btn.offsetWidth)){//包含原始宽度内边距边框,不包含外边框

// console.log(moveX);

var box=document.querySelector(".box");

//  console.log(downX);

border-radius: 4px;

};

4.效果

this.style.left=0;//将移动值赋值给滑块

function $(name){

}

拖动后获得与x轴距离减去初始值距离得到按钮移动的值

text.innerHTML="验证成功";

}  

width: 300px;

display: block;

//  alert("1");

//松开按钮

//拖到头,验证成功

if(moveX>-2){

.box{

var btn=document.querySelector(".btn");

line-height: 32px;

3)拖动

// function $(name){

btn.onmouseup=function(){

height:32px;

}

z-index: 3;

position: absolute;

}

btn.onmousedown=function(e){

return document.querySelector(name);

//拖到头,验证成功

// return document.querySelector(name);

btn.onmousemove=null;

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

var downX=e.clientX;  

z-index: 2;

btn.onmousemove=null;

text.innerHTML="验证成功";

var moveX=e.clientX-downX;

-webkit-margin-after: 1em;*/

}  

5.源码

//事件清除

2)按下

}  

// console.log(moveX);

var box=$(".box"),btn=$(".btn").....;  

相关热词:

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!

本文地址: https://v30.fanwenzhu.com/jz/wp/4997.shtml

Copyright © www.juheyunku.com      关于 | 合作 | 声明 | 联系 | 更新 | 地图 | Tags

js实现滑动滑块验证登录的具体代码

2020-12-18 编辑:

4.结束,松开按钮,按钮不可再次拖动

if(flag)return;

btn.onmousedown=null;

bg.style.width=moveX+"px";//背景

3.js事件

.bg{

width: 100%;

window.onload=function(){

}

var btn=document.querySelector(".btn");

//原生写法

1.按钮按下并移动

btn.onmousemove=null;

color: black;

position: absolute;

position: relative;

if(flag)return;

bg.style.width=0;//背景

1)

if(moveX>-2){

height: 100%;

this.style.left=moveX+"px";//将移动值赋值给滑块

js实现滑动滑块验证登录的具体代码 (https://www.wpmee.com/) javascript教程 第2张

// var box=$(".box"),btn=$(".btn").....;

// };

/*-webkit-margin-before: 1em;

btn.onmousemove=function(e){//拖动

2.事件状态:event对象(鼠标位置)event.clientX获得与X轴的距离

text.style.color="white";

}

1.html代码

或者使用封装选择器

//获取方法集合,可直接通过id, 类, 类型, 属性, 属性值等来选取元素(返回此名字的第一个)。

//移动范围

btn.onmousedown=function(e){//按下

js实现滑动滑块验证登录的具体代码 (https://www.wpmee.com/) javascript教程 第1张

flag=true;

}  

<!--背景-->

需要根据层级设置z-index保证滑动的正常使用

var text=document.querySelector(".text");

position: absolute;

js实现滑动滑块验证登录的具体代码 (https://www.wpmee.com/) javascript教程 第3张

left: 20px;

//事件清除

var bg=document.querySelector(".bg");

<a href="#" ><div>>></div></a>

text.style.color="white";

根据移动的值:判断按钮是否可以正常移动,判断按钮是否已经完成验证

<div>

bg.style.width=moveX+"px";//背景

flag=true;

line-height: 34px;

var box=document.querySelector(".box");

background-color: yellowgreen;

var bg=document.querySelector(".bg");

//封装选择器

分析使用过程:按住滑块并拖动可以移动,中途松开滑块返回起始位置,拖动至最后滑块不动

this.style.left=0;//将移动值赋值给滑块

top: 0;

// var e=event||window.event;

background: #e8e8e8;

border-radius: 4px;

border: 1px solid #ccc;

width: 40px;

}

z-index: 1;

2.css样式

btn.onmousedown=null;

<p>拖动滑块验证</p>

分析动作:

3.松开按钮回到原处

}

var downX=e.clientX; //按下后对x轴的距离

this.style.left=moveX+"px";//将移动值赋值给滑块

btn.onmousemove=null;

<!--滑块-->

<!--文字-->

background-color: #fff;

text-align: center;

//事件清除

最大的盒子相对定位,其他内部内容绝对定位

回到原处清除拖动

bg.style.width=0;//背景

btn.onmouseup=function(){

//移动范围

var flag=false;

btn.onmousemove=function(e){

text-align: center;

.btn{

</div>  

height: 34px;

if(moveX>=(box.offsetWidth-btn.offsetWidth)){//包含原始宽度内边距边框,不包含外边框

4)松开按钮

按下后获得与x轴的距离

//事件清除

.text{

var text=document.querySelector(".text");  

margin: 0;

//document.querySelector(".btn").onmousedown=function(event){//event事件状态

<div></div>

样式

}

//按下onmousedown 拖动onmousemove

var moveX=e.clientX-downX; //拖动后与x轴距离减去初始值距离,移动值

if(moveX>=(box.offsetWidth-btn.offsetWidth)){//包含原始宽度内边距边框,不包含外边框

// console.log(moveX);

var box=document.querySelector(".box");

//  console.log(downX);

border-radius: 4px;

};

4.效果

this.style.left=0;//将移动值赋值给滑块

function $(name){

}

拖动后获得与x轴距离减去初始值距离得到按钮移动的值

text.innerHTML="验证成功";

}  

width: 300px;

display: block;

//  alert("1");

//松开按钮

//拖到头,验证成功

if(moveX>-2){

.box{

var btn=document.querySelector(".btn");

line-height: 32px;

3)拖动

// function $(name){

btn.onmouseup=function(){

height:32px;

}

z-index: 3;

position: absolute;

}

btn.onmousedown=function(e){

return document.querySelector(name);

//拖到头,验证成功

// return document.querySelector(name);

btn.onmousemove=null;

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

var downX=e.clientX;  

z-index: 2;

btn.onmousemove=null;

text.innerHTML="验证成功";

var moveX=e.clientX-downX;

-webkit-margin-after: 1em;*/

}  

5.源码

//事件清除

2)按下

}  

// console.log(moveX);

var box=$(".box"),btn=$(".btn").....;  

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供学习参考!
本文地址为 https://v30.fanwenzhu.com/jz/wp/4997.shtml

相关文章

风云图片

推荐阅读

返回WordPress频道首页