أسلوب setProperty () لـ CSSStyleDeclusion
مثال
قم بتعيين خاصية CSS جديدة:
var declaration = document.styleSheets[0].cssRules[0].style;
var setprop = declaration.setProperty("background-color",
"yellow");
التعريف والاستخدام
يعين الأسلوب setProperty () خاصية CSS جديدة أو يعدلها في كتلة إعلان CSS.
دعم المتصفح
Method | |||||
---|---|---|---|---|---|
setProperty() | Yes | 9.0 | Yes | Yes | Yes |
بناء الجملة
object.setProperty(propertyname, value, priority)
قيمه المعامل
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 "" |
تفاصيل تقنية
إصدار DOM: | نموذج كائن CSS |
---|---|
قيمة الإرجاع: | غير معرف |
مزيد من الأمثلة
مثال
عيِّن خاصية CSS جديدة ذات أولوية "مهمة":
var declaration = document.styleSheets[0].cssRules[0].style;
var setprop = declaration.setProperty("background-color",
"yellow", "important");
مثال
تعديل خاصية CSS موجودة:
var declaration = document.styleSheets[0].cssRules[0].style;
var setprop = declaration.setProperty("color",
"blue");
❮ كائن CSSStyleDeclusion