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();

 

相关文章:

  • 2022-12-23
  • 2021-08-14
  • 2021-06-04
  • 2022-12-23
  • 2021-12-15
  • 2021-09-27
  • 2021-07-07
  • 2021-07-23
猜你喜欢
  • 2021-04-27
  • 2021-10-24
  • 2021-09-19
  • 2022-01-13
  • 2021-12-12
  • 2021-07-23
  • 2022-12-23
相关资源
相似解决方案