JS essay, CSS and JS prohibit page selection text, table's class style makes the TD Class style invalid, jquery get the element coordinates

Source: Internet
Author: User

CSS use User-select,user-select is not a standard, browser support is not complete; User-select has two values, none user can not select text, text user can select

body{
-moz-user-select:none; /* Firefox */
-webkit-user-select:none; /*webkit Browser */
-ms-user-select:none; /*ie10*/
-khtml-user-select:none; /* Early Browser */
User-select:none;
}

You can also use JS control

Document.body.onselectstart = Document.body.ondrag = function () {
return false;
}

The class in the TD is affected by the class contained in the table, making it ineffective, such as:

. ptable td{
background-color:red;
}
. ptd{
Background-color:blue;
}

<table class= "PTable" >
<tr>
<TD class= "PTd" >asdfs</td>
</tr>
</table>

In this case, the PTD will not work and need to be added to the!important.
. ptd{
Background-color:blue!important
;
}

jquery Gets the element coordinates

first, obtain the coordinates

1.offset ()

The offset () method returns or sets the offset (position) of the matching element relative to the document. (i.e. viewport coordinates)

The object returned by this method contains two integer properties: Top and left, in pixels.

This method is valid only for visible elements.

2.position ()

The position () method returns the position (offset) of the matching element relative to the parent element. (relative to the parent element's document coordinates)

The object returned by this method contains two integer properties: Top and left, in pixels.

This method is valid only for visible elements.

3.offsetParent ()

The OffsetParent () method returns the nearest ancestor anchor element.

The anchor element refers to the element's CSS position property that is set to relative, absolute, or fixed elements.

You can set position through JQuery, or through the position property of CSS.

second, to obtain the size

1.width () and height () methods

The width () method sets or returns the widths of elements (excluding padding, borders, or margins).

The height () method sets or returns the heights of the elements (excluding padding, borders, or margins).

2.innerWidth () and Innerheight () methods

The Innerwidth () method returns the width of the element, including the padding.

The Innerheight () method returns the height of the element, including the padding.

3.outerWidth () and Outerheight () methods

The Outerwidth () method returns the width of the element (including padding and borders).

The Outerheight () method returns the height of the element, including padding and borders.

The Outerwidth (True) method returns the width of the element (including padding, borders, and margins).

The Outerheight (True) method returns the height of the element (including padding, borders, and margins).

JS essay, CSS and JS prohibit page selection text, table's class style makes the TD Class style invalid, jquery get the element coordinates

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.