Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3634882
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T00:50:04+00:00 2026-05-19T00:50:04+00:00

I have following HTML <div id=finalTree> <ul> <li class=last style=display: list-item;> <a id=DataSheets href=#>Data

  • 0

I have following HTML

<div id="finalTree">  
<ul>  
 <li class="last" style="display: list-item;">  
 <a id="DataSheets" href="#">Data Sheets</a> 
</li></u>...........</div>

and I am first hiding all these li and then trying to show those li which match to selector. Here is my JavaScript. Here filterData is id of links.

function filterLeftNavTree(filterData){
    jQuery("ul.treeview").find("li").hide();
    var selectors =[];
    if(filterData.indexOf("|")!=-1){
        var filterData = filterData.split("|");
        for(i=0;i<filterData.length;i++){
            selectors.push('#'+filterData[i]);
        }  
        var filtered = selectors.join(',');
        $(filtered ).show();

    }else{  

        $('#'+filterData+).show();
    }  }  

the last two line doesn’t works…
any one can tell me what can be possible reason. Actually I tried to show li with :has, :contains, find().filter() but all these are taking too much time if I have large tree.

Do I am trying to show it by using multiple selector, but it’s not showing any thing. Any alternative having faster way to show it will be highly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T00:50:05+00:00Added an answer on May 19, 2026 at 12:50 am

    What you have (aside from the syntax error @verrerby mentioned) should be working, but why not cut down on that code a bit?

    You can slim things down by adding the # on every element after the first as part of the .join(), this also greatly simplifies the logic. You can reduce it down to:

    function filterLeftNavTree(filterData) {
      $("ul.treeview li").hide();
      $('#'+filterData.split('|').join(',#')).show();
    }
    

    Also note the change removing .find(), it’s faster in browser that support it to use a single selector, and just as fast in all the others.

    The only other possible reason I see for your code not working is jQuery is used for the hide and $ is used on the show, is it possible $ refers to something else? (e.g. ptototype?) To test just replace $ with jQuery on the .show() call.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following html <div id=menu> <ul class=horizMenu> <li id=active><a href=# id=current>About</a></li> <li><a
Suppose I have the following HTML: <div id=test> <span style=display:inline;>foo</span> <span style=display:none;>bar</span> <span style=display:inline;>baz</span>
I have the following html code: <div class=outer ui-draggable style=position: relative;> <div class=inner>Foo bar</div>
I have the following html code: <div class= modal id=indexModal> <span class=thing></span> <a href=#
I have following html: <div id=nav> <ul> <li class=keyitem>keyitem 1</li> <li>item</li> <li>item</li> <li>item</li> <li
I have following HTML: <g:HTMLPanel styleName={style.container}> </g:HTMLPanel> I want to display another div in
i have following html structure. <p class=expandableContent ><span class=label>Computer and Laptop Repairs</span></p> <div style=clear:
I have the following HTML: <div class="selfClear" style="float: left; border: 1px solid black;"> ...floated
I have the following HTML: <div class=tvShow align=left> <div class=clearfix style=margin:0px 0px;> <h3 class=left
I have the following HTML code: <div id=Activity class=rep_tb0 style=width: 100%> <div class=rep_tr0 style=width:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.