亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

kaedah jQuery css().

Kaedah

css() menetapkan atau mengembalikan satu atau lebih atribut gaya elemen yang dipilih.

Kembalikan sifat CSS

Untuk mengembalikan nilai sifat CSS yang ditentukan, sila gunakan sintaks berikut:

css("propertyname");

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
  $("button").click(function(){
    alert("背景顏色 = " + $("p").css("background-color"));
  });
});
</script>
</head>
<body>
<h2>這是一個標題</h2>
<p style="background-color:#ff0000">這是一個段落。</p>
<p style="background-color:#00ff00">這是一個段落。</p>
<p style="background-color:#0000ff">這是一個段落。</p>
<button>返回 p 元素的 background-color </button>
</body>
</html>

Tetapkan sifat CSS

Untuk menetapkan sifat CSS tertentu, sila gunakan sintaks berikut:

css("propertyname","value");

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
  $("button").click(function(){
    $("p").css("background-color","yellow");
  });
});
</script>
</head>
<body>
<h2>標題</h2>
<p style="background-color:#ff0000; width:200px;">段落1</p>
<p style="background-color:#00ff00; width:200px;">段落2</p>
<p style="background-color:#0000ff; width:200px;">段落3</p>
<p style="width:300px;">段落4</p>
<button>設(shè)置 p 元素的背景</button>
</body>
</html>

Tetapkan berbilang sifat CSS

Untuk menetapkan berbilang sifat CSS, sila gunakan sintaks berikut:

css({"propertyname":"value ", "propertyname":"value",...});

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
  $("button").click(function(){
    $("p").css({"background-color":"yellow","font-size":"200%"});
  });
});
</script>
</head>
<body>
<h2>標題</h2>
<p style="background-color:#ff0000; width:200px;">段落1</p>
<p style="background-color:#00ff00; width:200px;">段落2</p>
<p style="background-color:#0000ff; width:200px;">段落3</p>
<p style="width:300px;">段落4</p>
<button>設(shè)置 p 元素的背景</button>
</body>
</html>



Meneruskan pembelajaran
||
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> <script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("button").click(function(){ $("div").css({color:"red",fontSize:20,backgroundColor:"yellow"}); }) }); </script> <style type="text/css"> div{ color:blue; background-color:green; width:100px; height:100px; margin-top:5px; } </style> </head> <body> <div>仔細查看變化</div> <div>仔細查看變化</div> <br> <button>點擊查看效果</button> </body> </html>