Implementation of JavaScript implementation slider sliding change value code _javascript tips

Source: Internet
Author: User
Recently done a tax on the function, it is worth saying that the slider implementation of this page. We all know that most of the real programmers are not familiar with the page and art.

I am also, but I prefer to do their own work to achieve. Don't say much nonsense. Image above:
Implementation results:

part of the JS code
Copy Code code as follows:

Window.onload = function ()
{
var Owin = document.getElementById ("Win");
var bdrag = false;
var disx = Disy = 0;
Owin.onmousedown = function (event)
{
var event = Event | | window.event;
Bdrag = true;
DISX = Event.clientx-owin.offsetleft;
This.setcapture && this.setcapture ();
return False
};
Owin.onmousemove = function (event)
{
if (!bdrag) return;
var event = Event | | window.event;
var IL = Event.clientx-disx;
var MaxL = 480;
Il = il < 0? 0:il;
Il = il > maxL? Maxl:il;
OWin.style.marginTop = OWin.style.marginLeft = 0;
OWin.style.left = IL + "px"; The slider's position from the left
document.getElementById ("Hkline"). Style.width = IL; The width of the green entry on the left side of the slider
return False
};
Document.onmouseup = Window.onblur = Owin.onlosecapture = function ()
{
Bdrag = false;
Owin.releasecapture && owin.releasecapture ();
};
};

Description
1, the main use of onmousedown and onmousemove recorded after the drag position. And then through the DOM operation to change the corresponding component rendering
Note:
Because the company network is not very ideal. When you get home, you upload all the source code.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.