当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


HTML5 MathML selection属性用法及代码示例


HTML5中的MathML选择属性用于指定应用于查看的子元素。此值可以在1到元素的子代数之间。此属性的默认值为1,这意味着默认情况下将查看所有选项的第一个子元素。此属性被<maction>标记接受。

用法:

<element selection="index">

属性值:该属性具有上述和以下描述的单个值:

  • index:它包含要查看的子元素的索引。

下面的示例说明了MathML选择属性:

例:



HTML

<!DOCTYPE html> 
<html> 
  
<body> 
    <center> 
        <h1 style="color:green"> 
            GeeksforGeeks 
        </h1> 
        <h3>HTML5 MathML selection Attribute</h3> 
        <math> 
  
            <!-- Selecting the first  
            option by default -->
            <maction actiontype="toggle" selection="1"> 
                <mfrac> 
                    <mn>25</mn> 
                    <mn>10</mn> 
                </mfrac> 
                <mfrac> 
                    <mrow> 
                        <mn>5</mn> 
                        <mo>⋅</mo> 
                        <mn>5</mn> 
                    </mrow> 
                    <mrow> 
                        <mn>2</mn> 
                        <mo>⋅</mo> 
                        <mn>5</mn> 
                    </mrow> 
                </mfrac> 
                <mfrac> 
                    <mn>5</mn> 
                    <mn>2</mn> 
                </mfrac> 
            </maction> 
  
            <!-- Selecting the second 
            option by default -->
            <maction actiontype="toggle" selection="2"> 
                <mfrac> 
                    <mn>35</mn> 
                    <mn>14</mn> 
                </mfrac> 
                <mfrac> 
                    <mrow> 
                        <mn>7</mn> 
                        <mo>⋅</mo> 
                        <mn>5</mn> 
                    </mrow> 
                    <mrow> 
                        <mn>7</mn> 
                        <mo>⋅</mo> 
                        <mn>2</mn> 
                    </mrow> 
                </mfrac> 
                <mfrac> 
                    <mn>5</mn> 
                    <mn>2</mn> 
                </mfrac> 
            </maction> 
        </math> 
  
        <p>Click the number</p> 
  
    </center> 
</body> 
  
</html>

输出:

支持的浏览器:下面列出了HTML5 MathML选择属性支持的浏览器:

  • Firefox




相关用法


注:本文由纯净天空筛选整理自skyridetim大神的英文原创作品 HTML5 MathML selection Attribute。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。