JQuery common CSS operation

 

JQuery common CSS operation

  • $ (Elem) .css (obj): Set inline style
  • $ (Elem) .position (): returns the position of the container relative to the parent, can not be set only get
  • $ (Elem) .offset (obj): return relative to the top left position, both can get set
  • $ (Elem) .scrollTop (num): Returns the position of the scrollbar, set the scroll bar position
  • $ (Elem) .width (num): set the width, the width of the acquisition
  • $ (Elem) .height ( "50px"): set the height, the height of acquiring
  • $ (Elem) .addClass (className1 className2): Add class
  • $ (Elem) .removeClass (className1 className2): Delete class
  • $ (This) .toggleClass ( "div1", bool): switch, true can be, false not

toogleClass div to Add / Remove a class named div1

 $("div").addClass("div0").click(function(){
                $ ( The this ) .toggleClass ( "DIV1"); // can switch 
                // $ (the this) .toggleClass ( "DIV1", to true); // can only be switched over 
                // $ (the this) .toggleClass ( "DIV1 ", false); // can not be switched 
            })

 Get width and height:

  • $ (Elem) .width (num): Gets / sets the width (height no arguments returns, otherwise the object JQ)
  • $ (Elem) .height (num): Gets / sets the height (height without return parameters, otherwise the object JQ)
  • $ (Elem) .innerWidth (num): Gets / sets the padding + content (no parameters return wide, otherwise the object JQ)
  • $ (Elem) .innerHeight (num): Gets / sets the padding + content (no parameters returns high, otherwise the object JQ)
  • $ (Elem) .outerWidth (para): no parameters acquired content + margin + padding, for the parameter values ​​provided outerWidth, acquiring parameters representing the bit width (content + padding + margin + border) is true

Guess you like

Origin www.cnblogs.com/ltfxy/p/12332257.html