JQuery obtains the outerWidth and outerHeight Methods containing margin.

Source: Internet
Author: User

JQuery obtains the outerWidth and outerHeight Methods containing margin.

This article mainly introduces jQuery's method of obtaining outerWidth and outerHeight containing margin, which involves the usage skills of outerWidth and outerHeight in jQuery. It has some reference value. If you need it, you can refer

 

 

This example describes how jQuery obtains outerWidth and outerHeight containing margin. Share it with you for your reference. The details are as follows:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

<! DOCTYPE html>

<Html>

<Head>

<Script src = "js/jquery. min. js">

</Script>

<Script>

$ (Document). ready (function (){

$ ("Button"). click (function (){

Var txt = "";

Txt + = "Width of div:" + $ ("# div1"). width () + "</br> ";

Txt + = "Height of div:" + $ ("# div1"). height () + "</br> ";

Txt + = "Outer width of div (margin encoded DED):" + $ ("# div1"). outerWidth (true) + "</br> ";

Txt + = "Outer height of div (margin included):" + $ ("# div1"). outerHeight (true );

$ ("# Div1" ).html (txt );

});

});

</Script>

</Head>

<Body>

<Div id = "div1" style = "height: 100px; width: 300px; padding: 10px; margin: 3px; border: 1px solid blue; background-color: lightblue;">

</Div>

<Br>

<Button> Display dimensions of div </button>

<P> outerWidth (true)-returns the width of an element (bounded des padding, border, and margin). </p>

<P> outerHeight (true)-returns the height of an element (partition des padding, border, and margin). </p>

</Body>

</Html>

I hope this article will help you with jQuery programming.

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.