javascript - Hide elements after clicking a button -


using jquery, when click on search documents want hide li elements have aria-label contains company in vlaue. here html:

<ul class="ui-autocomplete ui-front ui-menu ui-widget ui-widget-content" id="ui-id-1" tabindex="0" style="display: none; top: 30px; left: 0px; width: 236px;">     <li class="search-documents-btn ui-menu-item" aria-label=" search documents &amp;raquo;" id="ui-id-111" tabindex="-1">         search documents »     </li>     <li class="search-category ui-menu-item" id="ui-id-112" tabindex="-1">         companies     </li>     <li aria-label="test" class="ui-menu-item" id="ui-id-113" tabindex="-1">      </li>     <li aria-label="test1" class="ui-menu-item" id="ui-id-114" tabindex="-1">      </li>     <li class="search-category ui-menu-item" id="ui-id-122" tabindex="-1">         branches     </li>     <li aria-label="test2" class="ui-menu-item" id="ui-id-127" tabindex="-1">      </li>     <li aria-label="test3" class="ui-menu-item" id="ui-id-128" tabindex="-1">      </li> </ul> 

any suggestions?

you can use filter() hide elements have aria-label contains company. try this:

$('#ui-id-111').on('click', function() {     $(this).closest('ul').find('li').filter(function() {         return $(this).attr('aria-label').indexof('company') != -1;     }).hide(); }); 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -