Why removeClass can't remove the class attribute

problem description: when you click .nav _ li, get the child element ul in .nav _ li, and then add the nav_li_on_2 class attribute to it. When I click on other peer buttons of .nav _ li, I will remove the class attribute added by ul in the current .nav _ li, but the following code can only be added and not deleted.

    <script type="text/javascript">
        // JS
        $(document).ready(function(){
            $(".nav_li").click(function(){
                $(this).find("ul").addClass("nav_li_on_2").siblings(".nav_li_on_2").removeClass("nav_li_on_2")
            })
        })
    </script>
Aug.09,2021

$(".nav_li").click(function(){
    $(this).find('ul').addClass("nav_li_on_2")
    $(this).siblings().find('ul').removeClass("nav_li_on_2")
})

print $(this). Find ('ul'). Siblings (' .nav _ li_on_2'), length is 0) means that


 $(this).find('ul').addClass("nav_li_on_2").siblings('.nav_li_on_2').removeClass("nav_li_on_2")
 //ulclass class ul  
 

siblings () is looking for a brother element. There is something wrong with the writing.

Menu