国产一级av国产免费_欧美丰满熟妇bbbbbb乱大交_日本少妇被黑人啪啪高潮_久久人人爽人人片

怎么在js里面添加css的樣式,在JS中添加CSS樣式的標(biāo)題可以是,,JS中添加CSS樣式的方法

前端小編 4 0

在JavaScript中添加CSS樣式有多種方法,以下是一些常見(jiàn)的做法:

1、使用style屬性

- 你可以直接在HTML元素上使用style屬性來(lái)添加CSS樣式。

```html

<div id="myDiv" style="color: red; background-color: blue;">Hello World!</div>

```

- 也可以在JavaScript中動(dòng)態(tài)設(shè)置樣式:

```javascript

document.getElementById('myDiv').style.color = 'red';

document.getElementById('myDiv').style.backgroundColor = 'blue';

```

2、使用CSSStyleSheet

- 可以通過(guò)CSSStyleSheet接口創(chuàng)建或修改樣式表。

```javascript

var styleSheet = document.styleSheets[0]; // 獲取***個(gè)樣式表

styleSheet.insertRule('div { color: red; }', 0); // 在樣式表中添加規(guī)則

```

3、使用createElement和appendChild

- 可以創(chuàng)建一個(gè)新的style元素,并將其添加到文檔中:

```javascript

var styleElement = document.createElement('style');

styleElement.innerHTML = 'div { color: red; }';

document.head.appendChild(styleElement);

```

4、使用MutationObserver

- 如果需要在樣式變化時(shí)做出響應(yīng),可以使用MutationObserver來(lái)監(jiān)視樣式表的更改:

```javascript

var observer = new MutationObserver(function(mutations) {

mutations.forEach(function(mutation) {

if (mutation.type === 'childList') {

console.log('A child node has been added or removed.');

} else if (mutation.type === 'attributes') {

console.log('The ' + mutation.attributeName + ' attribute has changed.');

} else if (mutation.type === 'style') {

console.log('A style has changed.');

} else if (mutation.type === 'characterData') {

console.log('Character data has changed.');

} else if (mutation.type === 'document') {

console.log('The entire document has been replaced.');

} else if (mutation.type === 'document-charset') {

console.log('The document\'s character set has changed.');

} else if (mutation.type === 'document-title') {

console.log('The document\'s title has changed.');

} else if (mutation.type === 'document-language') {

console.log('The document\'s language has changed.');

} else if (mutation.type === 'document-version') {

console.log('The document\'s version has changed.');

} else if (mutation.type === 'document-content-type') {

console.log('The document\'s content type has changed.');

} else if (mutation.type === 'document-root-element') {

console.log('The document\'s root element has changed.');

} else if (mutation.type === 'document-complete') {

console.log('The document has completed loading.');

} else if (mutation.type === 'document-visibility-change') {

console.log('The document\'s visibility has changed.');

} else if (mutation.type === 'document-language-change') {

console.log('The document\'s language has changed.');

} else if (mutation.type === 'document-title-change') {

console.log('The document\'s title has changed.');

} else if (mutation.type === 'document-charset-change') {

console.log('The document\'s character set has changed.');

} else if (mutation.type === 'document-version-change') {

console.log('The document\'s version has changed.');

} else if (mutation.type === 'document-content-type-change') {

console.log('The document\'s content type has changed.');

} else if (mutation.type === 'document-root-element-change') {

console.log('The document\'s root element has changed.');

} else if (mutation.type === 'document-complete-change') {

console.log('The document has completed loading.');

} else if (mutation.type === 'document-visibility-change-change') {

console.log('The document\'s visibility has changed.');

} else if (mutation.type === 'document-language-change-change') {

console.log('The document\'s language has changed.');

} else if

 
QQ在線咨詢(xún)
QQ咨詢(xún)
627619058
微信咨詢(xún)
hc16716
国产一级av国产免费_欧美丰满熟妇bbbbbb乱大交_日本少妇被黑人啪啪高潮_久久人人爽人人片
91精品国产综合久久久久久白拍| 高清真实交videos乱偷拍| www.久久av| 精品少妇人妻av一区二区 | 成熟人妻换╳╳╳╳Ⅹ| 国产99久久久国产精品| 丰满人妻av一区二区三区| 尤物精品视频在线观看| 在线观看黄色片网站| 国产伦精品一区二区三区视频金莲| 国产精品久久久区三区天天噜| 成人精品| 糈精国产xxxx在线观看| 国产人妻精品一区二区三区不卡| 久久夜色噜噜噜av一区二区 | 中文字幕人妻系列一区| 嫩草av在线| 国产精品一区二三区好的精华液| 肉大捧一出免费播放视频| 日本人妻久久久中文字幕免费| 久久久999国产精品| 日本黄页视频| 久久久久人妻精品一区三寸| 亚洲国产精品99久久久久| 国产黄三级三级三级| 久久综合九色综合欧美狠狠| 国产毛片精品| 人人妻人人澡人人爽人人添| 性色av一区二区三区免费| 扒开老女毛荫荫的黑森林视频| 亚洲欧美成人一区二区三区| 久久久久久毛片免费看| 国产精品扒开腿做爽| 99热色| 国产精品久久久久久吹潮| 激情视频中文字幕| 亚洲乱码国产乱码精品天美传媒| 欧美jiizzhd精品欧美| 午夜精品久久久久久久久久久久久蜜桃| 久久综合桃花网| 日本免费在线看|