Css方法
// Getting CSS properties $("h1").css("fontSize"); // returns a string such as "19px" $("h1").css("font-size"); // also works // Setting CSS properties $("h1").css( "fontSize", "100px" ); // setting an individual property // setting multiple properties $("h1").css({ fontSize: "100px", color: "red" });
Styling方法
// Working with classes var $h1 = $("h1"); $h1.addClass("big"); $h1.removeClass("big"); $h1.toggleClass("big"); if ( $h1.hasClass("big") ) { ... }
Dimensions
// Basic dimensions methods // sets the width of all H1 elements $("h1").width("50px"); // gets the width of the first H1 $("h1").width(); // sets the height of all H1 elements $("h1").height("50px"); // gets the height of the first H1 $("h1").height(); // returns an object containing position // information for the first H1 relative to // its "offset (positioned) parent" $("h1").position();
微信公众号: 架构师日常笔记 欢迎关注!