In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces the style operation in jquery, which is very detailed and has a certain reference value. Friends who are interested must finish reading it!
Jquery style operation: 1, use css () to set or return the style properties of the matching element; 2, use height () to set or return the height of the matching element; 3, use offset () to return the position of the first matching element relative to the document; 4, use offsetParent () to return the nearest positioning ancestor element, and so on.
The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.
Style manipulation in jquery
1. Css ()
The css () method returns or sets one or more style properties of the matching element.
Syntax:
/ / returns the style attribute value $(selector) .css (name) / / sets the style attribute $(selector) .css (name,value) $(selector) .css ({property:value, property:value,...})
2. Height ()
The height () method returns or sets the height of the matching element.
Syntax:
/ / returns the style height $(selector) .height () / / sets the style height $(selector) .height (length)
3. Width ()
The width () method returns or sets the width of the matching element.
Syntax:
$(selector) .width () $(selector) .width (length)
4. Offset ()
The offset () method returns or sets the offset (position) of the matching element from the document.
Syntax:
$(selector) .offset () $(selector) .offset (value)
5. OffsetParent ()
The offsetParent () method returns the nearest ancestor location element.
A positioning element refers to an element whose CSS position attribute is set to relative, absolute, or fixed.
You can set position through jQuery, or through the position property of CSS.
Syntax:
(selector) .offsetParent ()
6. Position ()
The position () method returns the position (offset) of the matching element relative to the parent element.
The object returned by this method contains two integer properties, top and left, in pixels.
This method is valid only for visible elements.
Syntax:
(selector) .position ()
7. ScrollLeft ()
The scrollLeft () method returns or sets the horizontal position of the scroll bar of the matching element.
The horizontal position of the scroll bar refers to the number of pixels scrolled from its left. When the scroll bar is on the far left, the position is 0.
Syntax:
/ / returns the horizontal scroll bar position $(selector) .scrollLeft () / / sets the horizontal scroll bar position $(selector) .scrollLeft (position)
8. ScrollTop ()
The scrollTop () method returns or sets the vertical position of the scroll bar of the matching element.
Scroll top offset refers to the offset of the scroll bar relative to its top.
If the method does not set a parameter, it returns the offset in pixels relative to the top of the scroll bar.
Syntax:
$(selector) .scrollTop (offset) above are all the contents of this article entitled "what are the style Operations in jquery?" Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.