JSFiddle - React, Tailwind, and code Playground

HTML

<input type="text" id="search" name="searchword" value="" />
<ul id="search_list">
    <li>first</li>
    <li>second</li>
    <li>third
        <ul>
            <li>aaa</li>
            <li>bbbb
                <ul>
                    <li>111111</li>
                    <li>22222</li>
                    <li>3333</li>
                </ul>
            </li>
            <li>cccc</li>
        </ul>
    </li>
</ul>

JavaScript

$(function() {
    
    $('#search').change(function() {
       var searchTerms = $(this).val();
    
       $('li').each(function() {
          $(this).toggle($(this).is(':contains(' + searchTerms  + ')'));
       });
    });
 
    
});