First, define a JavaScript function , as follows:
function Puckermenu (level) {
var levellength = (' row ' + level). Length;
var toDo = ' 0 ';
for (var icount = 0; icount < document.all.length; icount++) {
if (document.all[icount].id.indexof (' row ' + level) > 1 && (Document.all[icount].id.length > Levellength) {
if document.all (' level ' + level). Src.index Of (' Minus.gif ') >-1) {
Document.all[icount].style.display = ' none ';
ToDo = ' 1 ';
} else {
Document.all[icount].style.display = ' block ';
ToDo = ' 0 ';
}}} if (ToDo = = ' 1 ') {
document.all (' level ' + level). src = ' images/plus.gif ';
} else {
document.all (' level ' + level). src = ' images/minus.gif ';
}
}
Second, then on the Web page to define one div and one ul , note div to include a id level start image and an onclick event, ul id to include row , by default, is expanded, if you need to default to closed, You want to ul join in thestyle="display:none"
Examples are as follows:
<body>
<divstyle= "Cursor:hand"
onclick= "Puckermenu (' 1 ');" >public class dataaccess</div>
<ulid=row1>
<li> private string connstring;
<divstyle= "Cursor:hand"
onclick= "Puckermenu (' 2 ');" >protected dbconnection openconnection () </div>
< Ulid=row2style= "Display:none" >{...} </ul>
<li>
other
</ul>
</body>
Summarize
The above is the entire content of this article, I hope to be able to help people in need. If you have questions, you can leave a message for discussion.