Jquery dynamically changes the div width and height

Source: Internet
Author: User

Jquery dynamically changes the div width and height

This article mainly introduces how jquery dynamically changes the width and height of a div. The effect is very good and the compatibility is also good. If you need it, you can refer to it.

Complete code:

?

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

28

29

30

<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<Html xmlns = "http://www.w3.org/1999/xhtml">

<Head>

<Title> jquery dynamically changes the div width and height </title>

<Script type = "text/javascript" src = "jquery/jquery-1.11.2.min.js"> </script>

</Head>

<Body>

<Div>

<Input id = "addwidthkeleyi" value = "increase the width" type = "button"/>

<Input id = "cecewidthkeleyi" value = "width" type = "button"/>

<Input id = "addheightkeleyi" value = "add height" type = "button"/>

<Input id = "ceceheightkeleyi" value = "" type = "button"/>

Click the button and pay attention to the changes in the width of the div below </div>

<Div style = "border: 1px solid #999; width: 200px; height: 200px" id = "keleyidiv"> </div>

<Script type = "text/javascript">

$ ("# Addwidthke" + "leyi"). on ("click", function (){

$ ("# Keleyidiv"). width ($ ("# keley" + "idiv"). width () + 50 );

});

$ ("# Performancewidthk" + "eleyi"). on ("click", function (){

$ ("# Keleyidiv"). width ($ ("# kel" + "eyidiv"). width ()-50 );

});

$ ("# Addheightkele" + "yi"). on ("click", function (){

$ ("# Kel" + "eyidiv"). height ($ ("# keleyidiv"). height () + 50 );

});

$ ("# Performanceheightkeley" + "I"). on ("click", function (){

$ ("# Keleyidiv"). height ($ ("# keleyidiv"). height ()-50 );

});

</Script>

</Body>

</Html>

The above is all the content of this article. I hope you will like it.

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.