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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:50:24+00:00 2026-06-08T23:50:24+00:00

I need some help with this. Basically I have the following code which I

  • 0

I need some help with this. Basically I have the following code which I have been using. I’m not sure if will help or not…

$('#options-1').change(function () {
  -----blahblah
});

options-1 is my drop down menu. It has two options, one with value ‘1’ and another with value ‘2’. Could you guys please help me come up with something that does the following:

When I select the option with value ‘1’ it should do this:
1) Find an ‘li’ tag that includes an ‘img’ tag. The ‘IMG’ tag will have an ‘alt’ or ‘title’ attribute of 1, which corresponds to the value of the drop down menu (1).

2) The code should change the LI tag from:

class="" style="display: none;"

to

class="active" style="display: block;"

And, the same thing would happen if I select the option with the value ‘2’, or value ‘3’ or so on.

Thank you very much in advance! I would appreciate any help, suggestions, etc for this. As you can probably tell I’m not very experienced with javascript/jquery (yet :D).

  • 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-08T23:50:27+00:00Added an answer on June 8, 2026 at 11:50 pm

    assume your select tag looks like this:

    <ul id="yourUl">
        <li><img alt="1" /></li>
        <li><img title="2" /></li>
        <li><img alt="3" /></li>
    </ul>
    
    <select id="options-1">
        <option value="1">value 1</option>
        <option value="2">value 2</option>
    </select>
    

    so, your script will be:

    var findLi = function(val){
        $("ul#yourUl li img").each(function(){
            if($(this).attr("alt") == val || $(this).attr("title") == val)
                return $(this).parrent();
            return null;
        }
    };
    
    $(document).ready(function () {
        $("#options-1").change(function () {
            var val = $(this).val();
            val li = findLi(val);
            if(li == null)
                // do something to handle null or just ignore
            else
                $(li).addClass("active").css("display", "block");
        });
    });
    

    OR use has (thanks @Moin):

    $(document).ready(function () {
        $("#options-1").change(function () {
            var val = $(this).val();
            $("ul#yourUl li:has(img[alt='" + val + "']), ul#yourUl li:has(img[title='" + val + "'])").each(function() {
                $(this).addClass("active").css("display", "block");
            });
        });
    });
    

    OR

    $(document).ready(function () {
        $("#options-1").change(function () {
            var val = $(this).val();
            $("ul#yourUl li img").each(function () {
                if ($(this).attr("alt") == val || $(this).attr("title") == val)
                    $(this).parrent().addClass("active").css("display", "block");
            });
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I really need some help with this as I have been trying to fix
I would need some help with the following code if you are kind. Basically
I need some help on this one please, i basically have menuVIP.java, and vipKeyword.java.
I need some help understanding this bit of code pre { white-space: pre; white-space:
Need some help to solve this. I have a gridview and inside the gridview
I need some help to get this right, please. I have created an iPad
I need some help here. Can't seem to get a way around this. Basically
basically i need some algorithm that fits into the following problem: i have 5
i am new to java script and i need some help with following code
I have the following strange situation here I need some help with: I am

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.