javascript - if last li then set click event on it -


this xslt file:-

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform">   <xsl:output method="html" indent="yes" omit-xml-declaration="yes"/>    <xsl:template match="*" mode="item">     <li onclick="final()">       <xsl:value-of select="@value" />       <xsl:apply-templates select="current()[*]" />     </li>   </xsl:template>    <xsl:template match="*/*/*">     <ul>        <xsl:apply-templates select="*[1] | node()[current()/ancestor::*[3]]"                              mode="item" />     </ul>   </xsl:template> </xsl:stylesheet> 

this xml file:-

<?xml-stylesheet type="text/xsl" href="a.xsl"?>  <root>   <child_1 entity_id = "1" value="game" parent_id="0">     <child_2 entity_id="2" value="activities" parent_id="1">       <child_3 entity_id="3" value="physical1" parent_id="2">         <child_6 entity_id="6" value="cricket" parent_id="3">           <child_7 entity_id="7" value="one day" parent_id="6"/>         </child_6>       </child_3>       <child_4 entity_id="4" value="test1" parent_id="1">         <child_8 entity_id="8" value="test @ abc" parent_id="4"/>       </child_4>       <child_5 entity_id="5" value="test2" parent_id="1">         <child_9 entity_id="9" value="test @ xyz" parent_id="5"/>       </child_5>     </child_2>    <child_10 entity_id="10" value="region" parent_id="1">       <child_11 entity_id="11" value="abc" parent_id="10">         <child_12 entity_id="12" value="xyz" parent_id="11">           <child_13 entity_id="13" value="abc123" parent_id="12"/>         </child_12>       </child_11>   </child_10> </child_1> </root> 

i try create ul li xml file.
here set every li click event using onclick function.
want last li click event not every li.
like:-

  • activities
    • physical
      • cricket
        • one day

now want in last li

<li onclick ="final()">oneday</li> 

i changed xslt required one:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform">   <xsl:output method="html" indent="yes" omit-xml-declaration="yes"/>    <xsl:template match="*" mode="item">     <xsl:choose>       <xsl:when test="self::node()/child::*">         <li>           <xsl:value-of select="@value"/>           <xsl:apply-templates select="current()[*]"/>         </li>       </xsl:when>       <xsl:otherwise>         <li onclick="final()">           <xsl:value-of select="@value"/>           <xsl:apply-templates select="current()[*]"/>         </li>       </xsl:otherwise>     </xsl:choose>   </xsl:template>    <xsl:template match="*/*/*">     <ul>       <xsl:apply-templates select="*[1] | node()[current()/ancestor::*[3]]" mode="item"/>     </ul>   </xsl:template> </xsl:stylesheet> 

to output:

<ul>    <li>physical1       <ul>           <li>cricket             <ul>                 <li onclick="final()">one day</li>              </ul>          </li>        </ul>    </li> </ul>  <ul>    <li>abc       <ul>           <li>xyz             <ul>                 <li onclick="final()">abc123</li>              </ul>          </li>        </ul>    </li> </ul> 

Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -