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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:47:23+00:00 2026-05-21T17:47:23+00:00

I got this HTML structure: <form> <input class=myTrigger type=radio value=1/> <input class=myTrigger type=radio value=2/>

  • 0

I got this HTML structure:

<form>
    <input class="myTrigger" type="radio" value="1"/>
    <input class="myTrigger" type="radio" value="2"/>
    <fieldset>
        <ul class="class1">
            <li></li>
        </ul>
        <ul class="class2">
            <li></li>
        </ul>
    </fieldset>
    <fieldset>
        <ul class="class2">
            <li></li>
        </ul>
        <ul class="class2">
            <li></li>
        </ul>
    </fieldset>
</form>

With jQuery, I need to go through each ul and hide the ones that don’t have class myClass (wich is defined by the checked radio .myTrigger) then i need to check for the now empty fieldset‘s (ie: fieldsets where no ul has class myClass) and hide them entirely.

So far, i was able to hide the desired ul‘s, but not the fieldsets. This is what i got:

function myFunction() {

        var myClass = "class"+($("radio:checked").attr("value"));
        var productGroup = $("form ul");

        $("form fieldset").each(function(index){

            groupCheck = 0;

            $.each(productGroup, function(index, obj){
                if($(obj).hasClass(myClass))
                    {
                        groupCheck += 1;
                        $(obj).show();
                    }
                else
                    {
                        $(obj).hide();
                    };
            })

            if (groupCheck == 0)
                {
                    $(this).hide();
                }
            else {
                    $(this).show();
                };

        });

    };
myFunction();
$(".myTrigger").change(myFunction);

Also i got other scripts on the same page toggling the same ul’s
ex: (legend).click(function(){$(this).siblings("ul").toggle();});
so can’t hide the fieldsets based on the ul‘s beeing hidden already. instead I need to look for the classes (“myClass”) beeing present or not.

(ie: while the small script toogles the ul’s just for user convinience “myFunction” needs to filter the ul’s and fieldsets to be shown based on “myTrigger” selection.)

  • 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-21T17:47:24+00:00Added an answer on May 21, 2026 at 5:47 pm

    No need for loops; just target the things you want to show/hide with appropriate selectors:

    var myClass = 'class' + $('radio:checked:first').attr('value');
    
    // Hide all the <ul>s
    $('ul.' + myClass).hide();
    
    // First, show all the fieldsets, in case any were hidden earlier
    $('fieldset').show(); 
    
    // Now hide the ones that don't have any visible <ul>s inside
    $('fieldset:not(:has(ul:visible))').hide();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got this HTML form where I have multiple input elements: text, radio, and
I've got this structure: <div id=source1> <iframe src=foo.html></iframe> </div> <div id=source2> <iframe src=foo.html></iframe> </div>
I got this bad feeling about how I insert larger amounts of HTML. Lets
I got a problem like this (this is html/css menu): Eshop | Another eshop
In javascript, I've got a block of HTML like this: <h2>{title}</h2> <p><a href={url}>{content}</a></p> And
I've got HTML code that roughly looks like this: <li id=someid-11> <img src=... alt=alt
I got this error today when trying to open a Visual Studio 2008 project
I got this output when running sudo cpan Scalar::Util::Numeric jmm@freekbox:~/bfwsandbox/sa/angel/astroportal/dtu8e/resources$ sudo cpan Scalar::Util::Numeric [sudo]
I got this síngleton cache object and it exposes an IEnumerable property which just
I got this flash application where you can click a link while watching a

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.