Javascript _ javascript tips

Source: Internet
Author: User
This article mainly introduces how to change the display area size of content by dragging between left and right in JavaScript. It involves the skill of JavaScript responding to mouse events in real time to dynamically change the attribute of page elements. It has some reference value, for more information about how to change the area size of the content displayed by dragging between the left and right of JavaScript, see the example in this article. Share it with you for your reference. The details are as follows:

Here we will show the effect of the area to be dragged between the left and right sides. The red bars to the left will change the width of the area to be displayed. The right side will be displayed when you drag to the left, and the left side will be displayed when you drag to the right, like the QQ chat window, you can drag the size up or down to meet user requirements. This Code is fully implemented in combination with JavaScript and CSS code, and the compatibility of running in mainstream browsers is also good. We recommend you to drag the JavaScript code that changes the size left and right.

The running effect is as follows:

The Online Demo address is as follows:

Http://demo.jb51.net/js/2015/js-drug-cha-area-show-demo/

The Code is as follows:

 Left/right drag content display areaScript function $ (id) {return document. getElementById (id)} window. onload = function () {var oBox = $ ("box"), oTop = $ ("top"), oBottom = $ ("bottom "), oLine = $ ("line"); oLine. onmousedown = function (e) {var disX = (e | event ). clientX; oLine. left = oLine. offsetLeft; document. onmousemove = function (e) {var iT = oLine. left + (e | event ). clientX-disX); var e = e | returns invalid event,tarnameb+e.tar get | e. srcElement; var maxT = oBox. clientWight-oLine. offsetWidth; oLine. style. margin = 0; iT <0 & (iT = 0); iT> maxT & (iT = maxT); oLine. style. left = oTop. style. width = iT + "px"; oBottom. style. width = oBox. clientWidth-iT + "px"; $ ("msg "). innerText = 'top. width: '+ oLine. style. width + '--- bottom. width: '+ oBottom. style. width + '--- oLine. offsetLeft: '+ oLine. offsetLeft + '--- disX:' + disX + '--- tarnameb:' + tarnameb. tagName; return false}; document. onmouseup = function () {document. onmousemove = null; document. onmouseup = null; oLine. releaseCapture & oLine. releaseCapture ()}; oLine. setCapture & oLine. setCapture (); return false };}; script
 
  
Drag the red bar left and right to change the display area width.
 

  • JQuery beginner instance code set
  • More than 100 ExtJS application beginner instance Sets
  • JQuery-based provincial, municipal, and county cascade menus
  • A js album similar to QQ network shows special effects
  • EWebEditor v4.60 latest General Lite version
  • FCKeditor 2.6.4.1 Web Editor
  • JQuery smooth image scrolling
  • Xml + JS provincial, municipal, and county levels linkage menu
  • The effect of jQuery mouse sliding over the link text pop-up layer prompt
  • JS controllable image scroll effects (drive lights)

  • Code for large Banner ad effects and horizontal scrolling of images on the top of the webpage
  • FlexSlider web advertisement and image focus chart switching plug-in
  • JavaScript image switching compatible with IE and Firefox
  • JQuery imitation ios Wireless lan wifi tip effect (folding panel)
  • TopUp js Image Display and pop-up layer special effect code
  • JQuery-like Apple mobile phone magnifiers
  • Colortip text title alert plug-in
  • Webpage skin replacement, Ajax webpage style switch code set
  • Super big and beautiful blue web page pop-up Layer Effect
  • Code Implementation of the jQuery image preview function

I hope this article will help you design JavaScript programs.

Related Article

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.