tailieunhanh - Tương tác giữa PHP và jQuery - part 7

Để có được chiều cao hoặc chiều rộng của một phần tử, chiều cao (). Và chiều rộng (). Phương pháp rất tiện dụng. Cả hai trả về một giá trị mà không có đơn vị, có nghĩa là giá trị trả về là một số nguyên (nếu phần tử là 68 điểm ảnh cao. Chiều cao () sẽ trả lại 68). Điều này khác với. Css (), | CHAPTER 2 COMMON JQUERY ACTIONS AND METHODS .height and .width To obtain the height or width of an element the .height and .width methods are handy. Both return a value without units meaning the value returned is an integer if the element is 68 pixels high .height will return 68 . This differs from .css which will return the units of measure as well. Get the height of the form by running the following code Form height form .height px This outputs the following in the console Form height form .height px Form height 238px Note The actual height returned may vary on your browser depending on which operating system you re using. By passing a value to .height or .width a new value is set. Make all paragraphs on the page 100 pixels high with a yellow background using the following code p .height 100 .css background yellow Upon execution all paragraph heights change and their backgrounds become yellow see Figure 2-18 . Figure 2-18. The modified height and backgrounds ofall document paragraphs 61 CHAPTER 2 COMMON JQUERY ACTIONS AND METHODS .innerHeight .innerWidth .outerHeight and .outerWidth The inner height and width of an element is the width or height not counting borders or margins. You can access this information using the .innerHeight and .innerWidth methods. If you wish to include the borders in the height or width of the element use .outerHeight or .outerWidth . To include margins as well use .outerHeight true or .outerWidth true . Add a margin and border to the paragraph with class foo and then log its different widths and heights var el margin 20px border 2px solid black Inner Inner Outer Outer Outer width px height px width px height px width with margins true px Outer height with margins true px This outputs the following in the console var el .

TỪ KHÓA LIÊN QUAN
crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.