CSSStyleDeclaration setProperty () Yöntemi
Örnek
Yeni bir CSS özelliği ayarlayın:
var declaration = document.styleSheets[0].cssRules[0].style;
var setprop = declaration.setProperty("background-color",
"yellow");
Tanım ve Kullanım
setProperty() yöntemi, bir CSS bildirim bloğunda yeni bir CSS özelliği ayarlar veya mevcut bir CSS özelliğini değiştirir.
Tarayıcı Desteği
Method | |||||
---|---|---|---|---|---|
setProperty() | Yes | 9.0 | Yes | Yes | Yes |
Sözdizimi
object.setProperty(propertyname, value, priority)
Parametre Değerleri
Parameter | Description |
---|---|
propertyname | Required. A String representing the name of the property to set |
value | Optional. A String representing the new value |
priority | Optianal. A String representing if the property's priority should be set to
important or not. Legal values: "important" undefined "" |
Teknik detaylar
DOM Sürümü: | CSS Nesne Modeli |
---|---|
Geri dönüş değeri: | Tanımsız |
Daha fazla örnek
Örnek
"Önemli" önceliğe sahip yeni bir CSS özelliği ayarlayın:
var declaration = document.styleSheets[0].cssRules[0].style;
var setprop = declaration.setProperty("background-color",
"yellow", "important");
Örnek
Mevcut bir CSS özelliğini değiştirin:
var declaration = document.styleSheets[0].cssRules[0].style;
var setprop = declaration.setProperty("color",
"blue");
❮ CSSStyleBildirim Nesnesi