當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。