Cloud Stack Ninja

I am trying to get "Clothing" , "Bodysuit" "Shoes" , "All Shoes" values.

Here is what i tried :-

Please take a look at the code & share your thoughts

var filtered_category = jQuery('ul.dk_filter_middle-stage2-list ul li:first-child').contents().get(0).nodeValue;
    var parent_filtered_category = jQuery('ul.dk_filter_middle-stage2-list ul li:first-child').parents().find('#accordionItemhide li').contents().get(0).nodeValue; 
    
    console.log(filtered_category);
        console.log(parent_filtered_category);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="ok_filter_middle-stage2-container active" style="display: block;">
    <ul class="ok_filter_middle-stage2-list-title"><li><strong>Category</strong></li></ul>

    <ul class="ok_filter_middle-stage2-list">

      <div id="accordionItemhide" class="ok_filter_middle-stage2-list_wrapper">
        <li style="font-weight: normal;">Clothing<span>(2200)</span><img src="/media/images/default/filter_arrow_down_white.svg" alt=""><arrow></arrow></li>

        <div class="ok_filter_middle-stage2-category-list sub-category1">
          <ul role="listbox" tabindex="0" aria-label="folder list">
              <li data-value="2" tabindex="-1" role="option" class="active" aria-selected="false">Bodysuit<span>(200)</span></li><li data-value="8" tabindex="-1" role="option" class="active">Graphic Tees<span>(300)</span></li>                </ul>
        </div>
      </div>

      <div id="accordionItemhide" class="ok_filter_middle-stage2-list_wrapper">
        <li style="font-weight: normal;">Shoes<span>(1200)</span></li>

        <div class="ok_filter_middle-stage2-category-list sub-category2">
          <ul role="listbox" tabindex="0" aria-label="folder list">
            <li data-value="All Shoes" tabindex="-1" role="option" aria-selected="false">All Shoes<span>(10000)</span></li>
      </div>

    </ul>
  </div>



Read more here: https://stackoverflow.com/questions/64401481/get-specific-li-tag-values-using-jquery

Content Attribution

This content was originally published by Dev at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: