CSSStyleDeclaration setProperty () နည်းလမ်း
ဥပမာ
CSS ပိုင်ဆိုင်မှုအသစ်ကို သတ်မှတ်ပါ-
var declaration = document.styleSheets[0].cssRules[0].style;
var setprop = declaration.setProperty("background-color",
"yellow");
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
setProperty() နည်းလမ်းသည် အသစ်တစ်ခုသတ်မှတ်သည် သို့မဟုတ် CSS ကြေငြာပိတ်ဆို့ခြင်းတွင် ရှိပြီးသား CSS ပိုင်ဆိုင်မှုကို မွမ်းမံသည်။
Browser ပံ့ပိုးမှု
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 Object Model |
---|---|
ပြန်ပို့တန်ဖိုး- | သတ်မှတ်မထားသော |
နောက်ထပ် ဥပမာများ
ဥပမာ
"အရေးကြီး" ဦးစားပေးဖြင့် 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");
❮ CSSStyle Declaration Object