JS adds a selection area to the Div. Similar to the Windows desktop selection area, it is compatible with IE6, 7, 8, 9, 10, Firefox, Google, and all browsers.

Source: Internet
Author: User

First:

Compatibility:

IE6 is a little slow in response, and the effect is not as good as Firefox.

The main effect is to imitate the selection area of the Windows desktop. You can use the selection box selection icon.

Because there are too many JS Code, only a piece of core code is pasted.

JS core code:

// Select () {// create a constituency VaR _ down = false for the workspace; var Pos = {X: 0, Y: 0}; var move = {X: 0, Y: 0}; $ (". working "). mousedown (function (event) {// if it is right-click if (event. button = 2) return; // If (! Certificate (event.tar get ). is (". icons ") return; _ down = true; POS. X = event. clientx; POS. y = event. clienty; $ (". select ").css (" Left ", POS. x); $ (". select "example .css (" TOP ", POS. y); $ (". select "). show () ;}); $ (". working "). mousemove (function (event) {If (! _ Down) return; move. X = event. clientx; move. y = event. clienty; // subtract 2 compatible with ievar width = move. x-pos.x-2; var Height = move. y-pos.y-2; var select = $ (". select "); // select the left if (width> = 0 & height> margin 0most then select t.css (" width ", width+#select.css (" height ", height );} else {// The selection area extends to the right if (width <0) {// returns the absolute value var w=math.abs(width?#select.css ("width", w)+select.css ("Left", move. x); If (height> defaults 0)select.css ("height", height) ;}}if (height <= 0) {var hsf-math.abs(height1_1_select.css ("height", hsf-1_1_select.css ("TOP", move. y); If (width> 0th percentile select.css ("width", width) ;}}}); $ (". working "). mouseup (function () {_ down = false; $ (". select "detail .css (" width ", 0); $ (". select ").css (" height ", 0); $ (". select "). hide ();});}

Of course, the above effect also needs to be done with CSS. The complete dome will be sent over a period of time.

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.