ITPub博客

首页 > > > jquery学习手记(6)CSS, Styling, & Dimensions

jquery学习手记(6)CSS, Styling, & Dimensions

作者:zhmw 时间:2020-01-07 18:05:00 0 删除 编辑

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();
复制代码

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69901620/viewspace-3120193/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2018-12-04

  • 博文量
    295
  • 访问量
    9532