Click here to Skip to main content
15,886,823 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
example:
HTML
Clicking on B
<ul>
    <li>A</li>
    <li>B</li>
    <li>C</li>
</ul>
will change the html to 
<ul>
    <li>A</li>
    <li>
        B
        <ul>
            <li>B1</li>
        </ul>
    </li>
    <li>C</li>
</ul>
Clicking on B1 will change it to
<ul>
    <li>A</li>
    <li>
        B
        <ul>
            <li>
                B1
                <ul>    
                    <li>B11</li>
                </ul>
            </li>
            </li>
        </ul>
    </li>
    <li>C</li>
</ul>
Posted
Comments
Suvendu Shekhar Giri 24-Nov-15 0:41am    
What help you want from us?

1 solution

Please find sample code which will give you an idea to achieve your target by using jQuery. Later you can write similar code in better way.
HTML:
<ul>
    <li id="liFirst">A</li>
    <li id="liSecond">B</li>
    <li id="liThird">C</li>
</ul>

Script Code:
$("#liSecond").one("click",function() {
  $("#liSecond").append("<ul><li id="sceondChild">B1</li></ul>");
})
$("#liSecond").on("click", "li#sceondChild", function(){
  $("#sceondChild").append('<ul><li>B11</li></ul>');
})
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900