Example Analysis of CSS-DOM Operation in jQuery
This article mainly shows you the "sample analysis of CSS-DOM operations in jQuery", which is easy to understand and well-organized. I hope it can help you solve your doubts. Let the editor lead you to study and study the "sample analysis of CSS-DOM operations in jQuery".
In addition to css (), there are style manipulation methods to get and set the height, width, relative position of the element, and so on. The syntax is as follows:
Examples of height and width:
Demonstration example of CSS-DOM operation .hot {color: # ff0000;} a {color: # 000000; text-decoration: none } $(function () {/ / set height () and width () to $200 ("li"). Find ("span"). Css ({"display": "block", "border": "1px solid red"}) .width (200) .height (200);})
Apple iPad mini Samsung GALAXY III Apple iPhone 5s in hot sales of Xiaomi's MI 2 phone
Effect:
Example of relative position of element:
Demonstration example of CSS-DOM operation .hot {color: # ff0000;} a {color: # 000000; text-decoration: none } $(function () {/ / set height () and width () are both 200 / / $("li"). Find ("span"). Css ({"display": "block", "border": "1px solid red"}) .width (200) .height (200) / / offset $("input [type = 'button']") .click (function () {var x = ("span"). Offset (); console.log (x); $("span"). Text ("Abscissa:" + x.left+ ", ordinate:" + x.top);});})
Apple iPad mini Samsung GALAXY III Apple iPhone 5s in hot sales of Xiaomi's MI 2 phone
Effect:
The above is all the contents of the article "sample Analysis of CSS-DOM Operations in jQuery". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!