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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:14:55+00:00 2026-05-31T01:14:55+00:00

I have the following code where I want to show / hide different text

  • 0

I have the following code where I want to show / hide different text based upon a mouseover. I am using a data-global-id value and want to iterate through the children of the item-list and hide all but specified value (item-1 for data-global-id=1 for example):

<script>
  $(document).ready(function() {
    $('.item-list').hide();
    $('.h').mouseover(function() {
      // need to hide everything but the 1 or 2
      var id = $(this).data('global-id');
      var chil=$('.item-list').children();
      $.each(chil, function(i,v){
        alert(i);
        console.log(v);
      });
    });
  });
</script>

<style>
.h{
  width: 200px;
  border: 1px solid red;
}
</style>

<ul>
    <li><div class='h' data-global-id="1">Client 1</div></li>
    <li><div class='h' data-global-id="2">Client 2</div></li>
</ul>

<ul class="item-list">
    <li class="item-1">
        Lorem ipsum jtjtjt, etc...
    </li>
    <li class="item-2">
        Lorem ipsum, etc...
    </li>                      
</ul>

How would I specify in the each loop to hide everything and just show the item+data-global-id value? Is there a better / easier way to do this?

thx

  • 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-31T01:14:56+00:00Added an answer on May 31, 2026 at 1:14 am

    I’m not entirely sure if this is what you want, but I’ll give it a shot anyway,

    Since you’re already using jQuery for your project, you can do a direct search based on the data-global-id value as below

    //Provide the same global-id key to each .item-list member
    //Then do the following in your mouse over func
     var id = $(this).data('global-id');
     var chil=$('.item-list').children().show().
                 not('[data-global-id="'+ id +'"]').hide();
    

    Edit – Fiddle Added

    Check out the fiddle here

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

Sidebar

Related Questions

I have the following code to hide/show elements depending on what value is selected
I have the following code: $(#submenuSolutions).mouseleave(function () { $(.submenuRightCurrent).hide(); $(.submenuRightCurrent).removeClass(submenuRightCurrent); $(#prasentRight).addClass(submenuRightCurrent); $(#prasentRight).addClass(submenuRightCurrent).stop(true,true).show(); $(.menuHover).removeClass(menuHover); $(this).stop(true,true).hide();
I have the following code I want to run, but the problem is $this->type
I have the following code: [ [NSDate date] descriptionWithLocale: @yyyy-MM-dd ] I want it
I have the following code, which I want to load values on a selection
I have the following code: foreach (var control in this.Controls) { } I want
I have the following code in Ruby. I want to convert this code into
I have the following code: The actual problem is the non-quoted code. I want
I have the following code which works perfectly, but I want to allow access
I have the following code which works fine. However, I only want to return

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.