Home > Web Front-end > JS Tutorial > jQuery study notes Manipulating jQuery objects CSS processing_jquery

jQuery study notes Manipulating jQuery objects CSS processing_jquery

WBOY
Release: 2016-05-16 17:49:47
Original
1278 people have browsed it

CSSBasic attribute processing

方法

描述

css(name)

获取元素上CSS规则中name属性值

css(name,value)

css(name,fn(index,value))

css({name1:value1,…,nameN:valueN})

设置元素上CSS规则name属性的值为value,也可使用函数参数,不解释;还可以一次性为同一元素设置多个CSS属性

Method

Description

css(name)

方法

描述

height()

获取元素CSS属性height的值

width()

获取元素CSS属性width的值。这两个方法获取的是元素在页面中的实际高度宽度值,多用于数学运算,比较方便

innerHeight()

获取元素内部区域(包括内边距padding)的实际高度值

innerWidth()

获取元素内部区域的实际宽度值

outerHeight()

获取元素外部区域(包括内边距padding、边框border)的实际高度值

outerWidth()

获取元素外部区域的实际宽度值。若需计入外边距margin,可以传入一个true参数,即outerHeight(true)或outerWidth(true)

Get the name attribute value in the CSS rule on the element

css(name,value)

css(name,fn(index,value))

方法

描述

offset()

offset(coord)

offset(fn(index,coord))

获取元素在当前视窗的相对偏移,返回一个包含top和left属性的对象。比如$(“p”).offset().top。该方法只对可见元素有效。也可设置偏移值,注意coord也是个对象,比如$(“p”).offset({“top”:40,”left”:15})

position()

获取元素相对最近定位祖先元素的偏移值,同样返回一个包含top和left属性的对象。

scrollTop()

scrollTop(value)

获取垂直滚动条相对于该元素最顶端的偏移值

scrollLeft()

scrollLeft(value)

获取水平滚动条相对于该元素最左端的偏移值。两方法都可设置值,默认单位px,若value为负值则滚动条移动到最顶端或最左端;若value超出最大值则移动到最底端或最右端

css({name1:value1,…,nameN:valueN})

Set the value of the name attribute of the CSS rule on the element to value, or you can use function parameters without explanation; you can also set multiple CSS attributes for the same element at one time

CSSSize attribute processing

Method

Description

height()

Get the value of the CSS attribute height of the element

width()

Get the value of the element's CSS attribute width. These two methods obtain the actual height and width of the element on the page, which are mostly used for mathematical operations and are more convenient

innerHeight()

Get the actual height value of the internal area of ​​the element (including padding)

innerWidth()

Get the actual width value of the internal area of ​​the element

outerHeight()

Get the actual height value of the outer area of ​​the element (including padding and border)

outerWidth()

Get the actual width value of the outer area of ​​the element. If you need to include the outer margin, you can pass in a true parameter, namely outerHeight(true) or outerWidth(true)

CSSPosition attribute processing TR>

Method

Description

offset()

offset(coord)

offset(fn(index,coord))

Gets the relative offset of the element in the current window and returns an object containing top and left attributes. For example $("p").offset().top. This method only works on visible elements. You can also set the offset value. Note that coord is also an object, such as $("p").offset({"top":40,"left":15})

position()

Gets the offset value of the element relative to the most recently positioned ancestor element, and also returns an object containing top and left attributes.

scrollTop()

scrollTop(value)

Get the offset value of the vertical scroll bar relative to the top of the element

scrollLeft()

scrollLeft(value)

Gets the offset value of the horizontal scroll bar relative to the leftmost end of the element. Both methods can set the value. The default unit is px. If the value is negative, the scroll bar will move to the top or left end; if the value exceeds the maximum value, the scroll bar will move to the bottom or right end

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template