The JQuery Starter Tutorial (18): Manipulating the size of HTML elements __html

Source: Internet
Author: User

JQuery provides the following methods to control the size of HTML elements: width () height () innerwidth () innerheight () outerwidth () Outerheight ()

The diagram that generally affects the size of the HTML element is shown below:

JQuery width () and height () methods

Width () is used to set or get the width of the element, height () and the height of the element.

The following code gets the height and width of the <div> element.

$ ("button"). Click (function () {
   var txt= "";
   txt+= "width:" + $ ("#div1"). Width () + "</br>";
   txt+= "Height:" + $ ("#div1"). Height ();
   $ ("#div1"). HTML (TXT);
 });


The Innerwidth () and Innerheight () Methods of jquery
The innerwidth () return element includes the width of the padding, innerheight () returns the height that includes the padding.

The Outerwidth () and Outerheight () Methods of jquery
Outerwidth () returns the width that includes the padding and border, outerheight () returns the height including padding and border.

Outwidth (True) and Outheight (true) return the height and width of padding, border, and margin.

The following example sets the width and height of the specified element:

$ ("button"). Click (function () {
   $ (#div1). Width (. height);
 


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.