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 8922121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:45:11+00:00 2026-06-15T06:45:11+00:00

I’m having an issue with hiding and showing li elements with jQuery . My

  • 0

I’m having an issue with hiding and showing li elements with jQuery. My code works in Chrome and Internet Explorer 9, but if Internet Explorer 9 enters compatibility mode, or is set to a lower browser, it silently fails.

The idea is to have a drop down that filters by class and have the results paged. For the sample below, I have removed most of the paging code.

As far as I can tell, the issue is with selector.children().hide();, though I’m not certain about this.

I ran the HTML through the W3C validator, and it seems fine, while I get no JavaScript errors in the Chrome tools, and no obvious errors in the Internet Explorer development tools (though I am less familiar with these and could be missing something).

If you save the below into an HTML file, you should get a drop down that when selected filters the li elements. in Chrome at least:

<!DOCTYPE html>
<html>
    <head>
        <title>Test</title>
        <script src="http://code.jquery.com/jquery-latest.js"></script>
    </head>

    <body>
        <script>
            //<![CDATA[
                function buildPaging(filterClass) {
                    var selector = $('.paging');
                    selector.wrap("<div class='simplePagerContainer'></div>");

                    var pageSize = 2;
                    var pageCounter = 1;
                    var currentPage = 1;
                    var step =0;

                    selector.children().each(function (i) {
                        var item = $(this);
                        var hasClass = false;
                        if (filterClass !== undefined &&
                            filterClass !== '' &&
                            filterClass !== 'Sites:' &&
                            item.hasClass(filterClass)) {

                            hasClass = true;
                        }
                        else
                            if (filterClass === undefined ||
                                filterClass === '' ||
                                filterClass === 'Sites:') {

                                hasClass = true;
                            }

                        if (step < pageCounter * pageSize && step >= (pageCounter - 1) * pageSize && hasClass) {
                            $(this).addClass("simplePagerPage" + pageCounter);
                            step++;
                        }
                        else
                            if (hasClass) {
                                $(this).addClass("simplePagerPage" + (pageCounter + 1));
                                pageCounter++;
                                step++;
                            }
                    });
                    selector.children().hide();
                    selector.children(".simplePagerPage" + currentPage).show();
                };

                function cleanPaging() {
                    $('li').removeClass('simplePagerPage1 simplePagerPage2 simplePagerPage3 simplePagerPage4 simplePagerPage5 simplePagerPage6 simplePagerPage7 simplePagerPage8')
                    $('.simplePagerNav').remove();
                }

                $(document).ready(function() {
                   buildPaging();
                });

                var selectedItem;

                function hideMessage(period) {
                    var classList = $('.EMI_Message_Option');
                    selectedItem = period;
                    var keep;
                    for (var i = 0; i < classList.length; i++) {
                        if (classList[i].innerHTML !== period) {
                            $('.' + classList[i].innerHTML).hide();
                        }
                        else {
                            keep = classList[i].innerHTML;
                        }
                    }
                    $('.' + keep).show();
                    cleanPaging();
                    buildPaging(period);
                }
            //]]>
        </script>

        <div class="EMI_Messages">
            <div class="EMI_Messages">

            <div class="MessageDropdown">
                <select onchange="hideMessage(this.value)">
                    <option>Sites:</option>
                    <option>CSR</option>
                    <option>Sales</option>
                </select>
            </div>
            <ul class="paging">
                <li class="CSR">
                    <div>
                        <div>
                            <a href="http://example.com/">CSR</a>
                        </div>
                        <div>byline</div>
                        <div>11/26/2012 12:00:00 AM</div>
                    </div>
                </li>
                <li class="Sales">
                    <div>
                        <div>
                            <a href="http://example.com/">Sales</a>
                        </div>
                        <div>sample text</div>
                        <div>11/21/2012 12:00:00 AM</div>
                    </div>
                </li>
            </ul>
        </div>
        <div class="pager"></div>
        </div>
    </body>
</html>
  • 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-06-15T06:45:12+00:00Added an answer on June 15, 2026 at 6:45 am

    The problem seems to be caused by this piece of HTML:

    <select onchange="hideMessage(this.value)">
    

    In some versions of IE, this.value is not being passed as desired to the hideMessage() function. It is passed as an empty string so the code doesn’t work.

    It works for me if that is changed to this:

    <select onchange="hideMessage(this.options[this.selectedIndex].value)">
    

    FYI, here is your code with the fix applied in a jsFiddle: http://jsfiddle.net/jfriend00/9hUK9/

    Now that we see the problem, you can see a similar Q&A here: Getting the value of a SELECT box in Internet Explorer


    Unrelated to the problem you asked about, did you realize that every time you call buidPaging(), it does an additional .wrap("<div class='simplePagerContainer'></div>"); so your DOM structure gets deeper each time that is called?

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want to count how many characters a certain string has in PHP, but
I am reading a book about Javascript and jQuery and using one of the
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

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.