This is my first question sharing. Please let me know I need to change anything.
You are given a DOM tree and have to analyze the
<ol> list tags within it. Your task is to find the maximum depth of nested
<ul>/<ol> list tags. A single
<ul>/<ol> list is nested one level deep. Each
<ul>/<ol> list inside another
<ul>/<ol> list is nested one level deeper. If there are no
<ol> lists at all in the DOM tree, the depth of nesting is 0.
<ul>/<ol> lists can be nested directly or indirectly, that is, a
<ul> list inside a table inside an
<ol> list is nested two levels deep.
For example, given an HTML document with the following contents within the
<li>Item: <ol> <li>Point: <div> <ul> <li>elem1</li> </ul> </div> </li> </ol> </li> <li>elem2</li>
</ul> <ul> <li>simple list1</li> </ul> <ul> </ul>
there is a
<ul> list nested three levels deep. Namely “elem1” is an a
<ul> list which is inside an
<ol> list containing “Point”, while this
<ol> list is inside another
<ul> list containing “Item”.
Write a function:
that, given a DOM tree, returns the maximum depth of nested
For example, given the DOM tree of the document shown above, the function should return 3, as explained above.
- the DOM tree represents a valid HTML5 document;
- length if the HTMK document does not exceed 4KB;
- jQuery 2.1 is supported.