What I need is that, when loading the site, move the li element into the ul element based on the datta attr. I did it, but for some reason, it doesn't work.
<li class="classeul_name" data-nivelpai="BR04ZJCTF000">Nivel 1</li>
<li class="classeul_name" data-nivelpai="BR055XCTF003">Nivel 2</li>
<ul data-geral1="BR04ZJCTF000">
</ul>
<ul data-geral1="BR055XCTF003">
</ul>
jQuery
$(window).on("load", function(){
// Joga o nível 2
liName = $('.classeul_name').data('nivelpai');
$('li[data-nivelpai="'+liName+'"]').appendTo($('ul[data-geral1="'+liName+'"]'));
});
question from:
https://stackoverflow.com/questions/66065724/move-elements-with-jquery-based-on-data-attr-with-appendto 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…