我正在尝试创建一个菜单,每次单击链接时,它都会将父“li”与第一个链接交换,谁能告诉我该怎么做?
这是初始菜单:
<ul class="top-menu">
<li class="first-element"><a href="/">First</a><li>
<li class="second-element"><a href="/">Second</a><li>
<li class="third-element"><a href="/">Third</a><li>
<li class="fourth-element"><a href="/">Fourth</a><li>
</ul>
这是单击第四个链接后的菜单:
<ul class="top-menu">
<li class="fourth-element"><a href="/">Fourth</a><li>
<li class="second-element"><a href="/">Second</a><li>
<li class="third-element"><a href="/">Third</a><li>
<li class="first-element"><a href="/">First</a><li>
</ul>