HBCMS更多的中文手册参考:

addRule Method

DHTML文档教程

Creates a new rule for a style sheet.

dhtml语法

plNewIndex = styleSheet.addRule(sSelector, sStyle [, iIndex])

Parameters

sSelector Required. Stringthat specifies the selector for the new rule. Single contextual selectors are valid. For example, "div?a href="../objects/p.html">p?a href="../objects/b.html">b" is a valid contextual selector.
sStyle Required. Stringthat specifies the style assignments for this style rule. This style takes the same form as an inline style specification. For example, "color:blue" is a valid style parameter.
iIndex Optional. Integerthat specifies the zero-based position in the rules collection where the new style rule should be placed.
-1default. the rule is added to the end of the collection.

Return Value

Reserved. Always returns -1.

Remarks

You can apply rules to a disabled stylesheet, but they do not apply to the document until you enable the stylesheet.

DHTML代码范例

This example uses the addRule method to add a rule that sets all bold text appearing in a DIV to the color blue.

<STYLE>
</STYLE>
<DIV>
Internet Explorer makes <B>HTML</B> dynamic.
</DIV>
<SCRIPT>
var new_rule;
new_rule = document.styleSheets[0].addRule("DIV B", "color:blue", 0);
</SCRIPT>

是否符合公共标准

There is no public standard that applies to this method.

Applies To

styleSheet

更多语法参考

removerule, rules, styleSheets