php读取html中元素属性,读写HTML元素的css 属性
jQuery 的css()方法用來設置或讀取HTML元素的css屬性。
讀取元素的CSS語法語法如下:
css(“propertyname“);
比如下面代碼取得第一個
元素的背景顏色。
[javascript]
$("p").css("background-color");
$("p").css("background-color");
使用下面的語法來設置HTML元素的CSS屬性:
css(“propertyname“,”value“);
例如,下面代碼為所有
元素設置背景色為黃色。[html]
JQuery Demo$(document).ready(function () {
$("button").click(function () {
$("p").css("background-color", "yellow");
});
});
This is a heading
This is a paragraph.
This is a paragraph.
This is a paragraph.
This is a paragraph.
Set background-color of p
JQuery Demo$(document).ready(function () {
$("button").click(function () {
$("p").css("background-color", "yellow");
});
});
This is a heading
This is a paragraph.
This is a paragraph.
This is a paragraph.
This is a paragraph.
www.2cto.comSet background-color of p
css()也支持同時多個CSS屬性:其語法如下:
css({“propertyname“:”value“,”propertyname“:”value“,…});
比如:
[javascript] view plaincopyprint?
$("p").css({"background-color":"yellow","font-size":"200%"});
$("p").css({"background-color":"yellow","font-size":"200%"});
本文原創發布php中文網,轉載請注明出處,感謝您的尊重!
總結
以上是生活随笔為你收集整理的php读取html中元素属性,读写HTML元素的css 属性的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 买房子自己出百分之七十国家给补贴百分之三
- 下一篇: php不是预定义超全局变量,五、PHP知