Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-09-2009, 04:00 PM   PM User | #1
1andyw
Regular Coder

 
Join Date: Jul 2006
Posts: 171
Thanks: 13
Thanked 1 Time in 1 Post
1andyw is an unknown quantity at this point
JQuery: Selector problem with dl dt dd

Hi,

I am trying to show/hide dt>dd elements together, based on the dt having a class. I can't seem to identify a dd as a child of the dt.

Code:
<html>
<head>
<style type="text/css">
body{font: 15px/25px Arial;}
dt.consumer{color:#fff;}
dt.consumer dd{color:#000;background:#eee;}
</style>
  <script src="http://code.jquery.com/jquery-latest.js"></script>  
  <script>
  $(document).ready(function(){
    $("dt.consumer").css("background-color","gray");
    $("dt.consumer".dd).css("border", "3px double red");
  });
  </script>
  <style>
   </style>
</head>
<body><dl>
<dt class="consumer">Now is the time for all good men!</dt>
<dd>The party must wait!</dd>
<dt class="consum">Now is the time to eat!</dt>
<dd>Eating is great!</dd>
<dt class="drink">Now is the time to drink!</dt>
<dd>Who is kidding whom?</dd>
</dl>
</body>
</html>
How can I cause a given dd element to respond when the corresponding dt element is affected?

Andy

Last edited by 1andyw; 06-09-2009 at 07:17 PM.. Reason: RESOLVED
1andyw is offline   Reply With Quote
Old 06-09-2009, 05:31 PM   PM User | #2
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
Try

Code:
$("dt.consumer, dt.consumer > dd").css(...);
__________________
Fumigator is offline   Reply With Quote
Old 06-09-2009, 06:07 PM   PM User | #3
1andyw
Regular Coder

 
Join Date: Jul 2006
Posts: 171
Thanks: 13
Thanked 1 Time in 1 Post
1andyw is an unknown quantity at this point
Same result as original post.
1andyw is offline   Reply With Quote
Old 06-09-2009, 07:16 PM   PM User | #4
1andyw
Regular Coder

 
Join Date: Jul 2006
Posts: 171
Thanks: 13
Thanked 1 Time in 1 Post
1andyw is an unknown quantity at this point
Resolved.

Changed this:
Code:
$("dt.consumer > dd").css(". . .");
to this:
Code:
$("'dt.consumer' + dd").css(". . .");
1andyw is offline   Reply With Quote
Old 06-09-2009, 08:22 PM   PM User | #5
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
Ah, yes, of course... I assumed the dd tags were children of the dt tags (I must admit I didn't look at your html very carefully and jumped to this conclusion, in spite of the fact that I know dd tags do not belong as children to dt tags).

Nice solution.
__________________
Fumigator is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:18 PM.


Advertisement
Log in to turn off these ads.