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
i have following html structure. <p class=expandableContent ><span class=label>Computer and Laptop Repairs</span></p> <div style=clear:
I have the following snippet in one of my html pages : <div class=inputboximage>
i have following HTML structure: <div class=container> <div class=sidebar></div> <div class=content></div> <div class=subscript></div> </div>
I have following html: <div class=rows> <div class=row><input type=text onchange=javascript:getIndex(this); value= /></div> <div class=row><input
I have following HTML markup, <div id=subcontent_l> <p> <a href=/membership-packages/><img height=202 width=644 alt= src=http://74.52.72.231/wp-content/uploads/2010/06/banner1.jpg
I have following HTML code: <section class=indent-1> <!-- Section 1 --> <section> <div>Some content</div>
I have the following HTML: <div style=width: 143px; height: 125px; overflow: scroll;><select size=20 style=min-width:
I have the following HTML structure: <div><a href=link1>blah</a></div> <div><a href=link2>blah</a></div> <div><a href=link3.swf>blah</a></div> <div><a href=link4>blah</a></div>
I have the following HTML code: <div style=background-image:url(~/Images/MyImage.jpg); width:100%; height:100%> I'm not too familiar

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.