未来元素的添加删除

xiaoxiao2021-02-28  4

html

<ul class="tree"> <li> 一级 <ul class="ul-li-ul-li"> <li> Contact </li> <li> Blog </li> <li> Jobs </li> </ul> </li> <li> 一级 <ul class="ul-li-ul-li"> <li> file </li> <li> view </li> <li> code </li> </ul> </li> <li> 一级 <ul class="ul-li-ul-li"> <li> tools </li> <li> vcs </li> <li> help </li> </ul> </li> <li> 一级 <ul class="ul-li-ul-li"> <li> js </li> <li> css </li> <li> html </li> </ul> </li> </ul> <ul class="ul-ul-ul-ul"> </ul>

js

$('.ul-li-ul-li').on("click","li",function(){ $(this).remove(); $('.ul-ul-ul-ul').append($(this)); }); $('.ul-ul-ul-ul').on("click","li",function(){ $(this).remove(); $('.ul-li-ul-li').append($(this)); })
转载请注明原文地址: https://www.6miu.com/read-2400064.html

最新回复(0)