// 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"
});// Working with classes
var $h1 = $("h1");
$h1.addClass("big");
$h1.removeClass("big");
$h1.toggleClass("big");
if ( $h1.hasClass("big") ) { ... }// 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();来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69901620/viewspace-3120193/ ,如需转载,请注明出处,否则将追究法律责任。