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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:38:20+00:00 2026-05-31T13:38:20+00:00

Is there anyway to have nested jQuery selectors. For example: if the page also

  • 0

Is there anyway to have nested jQuery selectors.

For example:

if the page also has an ID = "LeadEditForm_Title" someplace on it then do the following…

jQuery("[id='A0.R0.Main Phone Number']").live('mousedown',function(e) {
    var container = $(this).width();
    var width_offset = -50;
    var top_offset = 25;
    var width = (container + width_offset).toString();
    jQuery(".mywidget").appendTo(document.body).css('width', width + 'px');
    jQuery(".mywidget").appendTo(document.body).css('position', 'absolute');
    jQuery(".mywidget").appendTo(document.body).css('top', ($(this).offset().top+top_offset).toString() + 'px');
    jQuery(".mywidget").appendTo(document.body).css('left', Math.round($(this).offset().left) + 'px');
});

QUESTION:

How do I do an if jQuery(".LeadEditForm_Title") then do the above??? basically a nested jQuery call… I’ve seen examples where they have :

 jQuery(function(){ // my code goes here }); 

But I want it to depend on the ID “.LeadEditForm_Title“.

  • 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-31T13:38:20+00:00Added an answer on May 31, 2026 at 1:38 pm

    To nest selectors, you use find:

    jQuery('#mySelectorId').find('.mySelectorClass')
    

    This is the same as doing this as well:

    jQuery('#mySelectorId .mySelectorClass')
    

    Being sure to put a space between. Without the space you are selecting an element with that ID and that class.

    I would also note that your code is probably not doing what you think it is:

    jQuery("[id='A0.R0.Main Phone Number']").live('mousedown',function(e) {
        var container = $(this).width();
        var width_offset = -50;
        var top_offset = 25;
        var width = (container + width_offset).toString();
        jQuery(".mywidget").appendTo(document.body).css('width', width + 'px');
        jQuery(".mywidget").appendTo(document.body).css('position', 'absolute');
        jQuery(".mywidget").appendTo(document.body).css('top', ($(this).offset().top+top_offset).toString() + 'px');
        jQuery(".mywidget").appendTo(document.body).css('left', Math.round($(this).offset().left) + 'px');
    });
    

    The last 4 jQuery(".mywidget") calls are adding the widget to the body each time. You really only want to add it once and change the css for each style:

    jQuery("[id='A0.R0.Main Phone Number']").live('mousedown',function(e) {
        var container = $(this).width();
        var width_offset = -50;
        var top_offset = 25;
        var width = (container + width_offset).toString();
        jQuery(".mywidget").appendTo(document.body).css('width', width + 'px').css('position', 'absolute').css('top', ($(this).offset().top+top_offset).toString() + 'px').css('left', Math.round($(this).offset().left) + 'px');
    });
    

    Which can also be reduced to one css call:

    jQuery("[id='A0.R0.Main Phone Number']").live('mousedown',function(e) {
        var container = $(this).width();
        var width_offset = -50;
        var top_offset = 25;
        var width = (container + width_offset).toString();
        jQuery(".mywidget").appendTo(document.body).css({
            width: width + 'px',
            position: 'absolute',
            top: ($(this).offset().top+top_offset).toString() + 'px',
            left: Math.round($(this).offset().left) + 'px';
        });
    });
    

    Note, outside of this, your id is not supposed to have spaces, according to HTML spec. And, if you have a valid id, you would select it like this:

    jQuery("#A0.R0.Main_Phone_Number")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there anyway to have javascript run when a XSL sheet has been applied
I'm using NHibernate. I have a class which has a nested type. Is there
Is there anyway to have a sort of virtual static member in C++? For
Is there anyway to have items in an ASP.NET DropDownList have either their Text
Is there anyway to have the var be of a nullable type? This implicitly
Is there anyway in XAML only to have a linebreak in a TextBox? I
Is there anyway I can create a not in clause like I would have
Is there anyway to find the date difference in php? I have the input
Is there anyway to extract the underlying xaml from a control. IE. I have
I have a question regarding using Semaphores HANDLE WINAPI CreateSemaphore(...); Is there anyway I

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.