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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:48:16+00:00 2026-05-27T14:48:16+00:00

This is def a newb question but after reading trough all the resources out

  • 0

This is def a newb question but after reading trough all the resources out there I still can’t figure out how this descendant thing works. I want to select all class link div’s contained in the art_menu div. How do I do that?

<div id="left">
    <div class="link">asdfgh</div>
    <div id="art_menu">
        <ul>
            <li><div class="link">bla bla</div><li>
            <li><div class="link">bla bla bla</div><li>
        </ul>
    </div>
</div>

I can select the first div, that’s outside the unordered list. I’ve tried with $(‘#art_menu ul li .link’).css(‘…’), that don’t work, I’ve tried $(‘#art_menu’).find(‘.link’).css(‘…’) that don’t work either. Can you please explain to me what I’m missing here?

edit: I’ve tried all the suggestions you gave me before, none of them work. the ul is injected dynamically with $(‘#art_menu’).load() and then .show(), could this be the problem?

$(document).ready(function() {
    $('#art_menu').load('get_cat.php');
    $("#art_menu").fadeIn();
    $('#art_menu .link').css("border","3px solid red"); 
} );
  • 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-27T14:48:17+00:00Added an answer on May 27, 2026 at 2:48 pm

    The problem is that you’re trying to operate on the links before they’re there:

    $(document).ready(function() {
        $('#art_menu').load('get_cat.php');
        $("#art_menu").fadeIn();
        $('#art_menu .link').css("border","3px solid red"); 
        // ^^ too soon, the `load `isn't complete yet
    } );
    

    That should be:

    $(document).ready(function() {
        $('#art_menu').load('get_cat.php', function() {
            // This callback happens after the load is complete
            $("#art_menu").fadeIn();
            $('#art_menu .link').css("border","3px solid red"); 
        });
    } );
    

    load is an asynchronous operation, the call to load just starts it. It completes some time later (when is dependent on network speeds and such). It has a callback it fires when the load is complete, which is where the code that needs to operate on the loaded content needs to go.

    See also the discussion in the “re your edit” below.


    Original answer:

    Your examples should work, but your HTML has a typo in two places: Your li elements are not closed, you’ve used <li> at the end instead of </li>. Here’s a fixed example:

    <div id="left">
        <div class="link">asdfgh</div>
        <div id="art_menu">
            <ul>
              <li><div class="link">bla bla</div></li>
              <li><div class="link">bla bla bla</div></li>
            </ul>
        </div>
    </div>
    

    Note that I also removed the display: none from the container, since otherwise we won’t see any effect of calling css on its descendants! With that, either of your exmaples should work (per the live link above).


    Re your edit:

    I’ve tried all the suggestions you gave me before, none of them work. the ul is injected dynamically with $('#art_menu').load() and then .show(), could this be the problem?

    Possibly, if your code trying to operate on them is called prior to their actually being there. If your code operating on them is called only after they’re actually there, the fact they were injected later is irrelevant.

    Here’s an updated working example using .load (live copy):

    jQuery(function($) {
    
      $("#theButton").click(function() {
        // This code runs when the button is clicked
        $("#art_menu").load("http://jsbin.com/azaxev", function() {
          // This code runs when the load is complete
          $("#art_menu .link").css("color", "green");
        });
      });
    
      // This code runs when there are no links, so we never
      // see any effect form it
      $("#art_menu .link").css("font-weight", "bold");
    
    });
    

    The end result is that the links are green but not bold, because the line making them bold runs before they’re there, and so has no effect.

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

Sidebar

Related Questions

This is a pretty frustrating newb question, but I can't seem to get iteration
If I do this: def foo(): a = SomeObject() Is 'a' destroyed immediately after
I tried this: def str1=good stuff 1) def str2 = str1.replaceAll('\)',' ') but i
I have methods in all of my models that look like this: def formatted_start_date
In ruby you can do something like this: def method(a, b) ... end myMethod(*myArray)
Is there any way to to this: def getChannelListJSON = { def results =
is there a way to do this def version=(version) self.revision = version end def
so my code looks like this: def parse(info): 'info' is a list made out
Suppose you had this: def wipeProduct(hash, nameToDelete) hash.each do |i| key = i[0] productName
I've got a model like this def upload_location(instance, filename): return 'validate/%s/builds/%s' % (get_current_user(), filename)

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.