ninenote thanks for this solution!.
I was hoping can you help me in a adding a class “dropdown” to all those list item has subpages below them
eg.
<ul>
<li class="page_item page-item-2"><a href="#">main 1</a></li>
<li class="dropdown page_item page-item-4"><ahref="#">main 2</a>
<ul class="children">
<li class="page_item page-item-6"><a href="#">Sub 1</a></li>
<li class="page_item page-item-9"><a href="#">Sub 2</a></li>
</ul>
</li>
</ul>
please help