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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:28:25+00:00 2026-06-07T16:28:25+00:00

Jquery Selector: //left side $(‘section.abstract label.gcsubheader’) //right side $(‘fieldset.abstract label.formElems’) Both Return: (with the

  • 0

Jquery Selector:

//left side
$('section.abstract label.gcsubheader')
//right side
$('fieldset.abstract label.formElems')

Both Return: (with the class differing, but the for="*" remaining the same)

<label for=​"design" class=​"displayHidden formElems">​Design​</label>​ 
<label for=​"expertise" class=​"displayHidden formElems">​Expertise​</label>​
<label for=​"skills" class=​"displayHidden formElems">​Skills​</label>​
<label for=​"tools" class=​"displayHidden formElems">​Tools​</label>​
<label for=​"projects" class=​"displayHidden formElems">​Projects​</label>​
<label for=​"community" class=​"displayHidden formElems">​Community​</label>​
<label for=​"interests" class=​"displayHidden formElems">​Interests​</label>​

I would like to append to the left selector something similar to the following:

.find($('label[for="' + $(this).text().toLowerCase() + '"]'))

or

var $this = $(this).text().toLowerCase();   //and use the $this in the concatenation:

to accomplish selecting elements with labels for="design" like the selector ($('label[for="design"]')), but by doing it dynamically. The idea is that I am trying refactoring for the first time, and have very many elements, and when I click on one element, I would like to find itself, and the other one that shares its label for string.

I have tried:

$('section.abstract label.gcsubheader').click(function () {
     var $this = $(this).text().toLowerCase();
     //left element - hide
     $('section.abstract label.gcsubheader')..find($('label[for="' + $this + '"]')).show();
     //Right Side - show
     $('fieldset.abstract label.formElems').find($('label[for="' + $this + '"]')).show();
}

and

$('fieldset.abstract label.formElems').find($('label[for="' + $(this).text().toLowerCase() + '"]')).show();

Not sure what I am doing wrong. Do I have to allow for another layer of abstraction to grab/define the element’s text, or is my syntax wrong, or something else off? I am hoping to get this, so I can then toggle both left and right’s .hidden class, providing a very robust refactoring of the code, maybe something like this?:

$('label[for="*"]').click(function () {
   // for each .toggleClass('hidden'); 
}

although not quite sure how to write the * or for each for that either, but I will get there. You help is greatly 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-06-07T16:28:28+00:00Added an answer on June 7, 2026 at 4:28 pm

    You have an extra . before your first find() call, as well as an unclosed string literal being passed as an argument to it. Note the closing brackets for both the inside function and the click method. You were also using .show() for the left element when you probably wanted .hide().

    Additionally, it’s perfectly fine to append the attribute equals selector to your original selector statement like this (I didn’t have your full html so the selector may need to be tweaked a little bit):

    $('section.abstract label.gcsubheader').click(function () {
        var $this = $(this).text().toLowerCase();
    
        //left element - hide
        $('section.abstract label.gcsubheader[for="' + $this + '"]').hide();
    
        //Right Side - show
        $('fieldset.abstract label.formElems[for="' + $this + '"]').show();
    });
    

    As for binding to any of your labels, consider using the has-attribute selector instead of for='*':

    $('label[for]').click( /* ... */ );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

http://jqueryui.com/demos/autocomplete/#combobox On the right hand side, there are selector tabs (with the selected arrow
I am using the following jquery code: $(#top ul li.corner).mouseover(function(){ $(span.left-corner).addClass(left-corner-hover); $(span.right-corner).addClass(right-corner-hover); $(span.content).addClass(content-hover); }).mouseout(function(){
Quick and silly jQuery selector question. Why this does not work : jsFiddle demo
I have a jquery selector which looks like this: $(#MasterListDVWP tr td:contains(' + currentSchool
I have a jQuery selector that queries elements by tag name and class. In
I have a jQuery selector that is running way too slow on my unfortunately
I've built a jQuery selector for a function which looks like this: $('html').not('.table-main tr[selected]').mousedown(
I have a jQuery selector: div div ul li.normal a, div div ul li.massive
I want to use a JQuery selector to grab an elelement if it is
I'm trying to create a jQuery selector that will do something like this: (.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.