0
<div id="slide2" class="slide" style="z-index:2;">
    <div style="display:none; z-index:1;position:absolute; bottom:10px;right:10px;padding:20px; background:#fff;border:solid 1px black;border-radius:15px;box-shadow: 4px 4px 3px #888888;" class="rss_qrcode"></div>
</div>

This works:

$('.rss_qrcode').css('display', 'block');

This does not work:

$('#slide2.rss_qrcode').css('display', 'block');

And I need to be able to manipulate only divs with the class rss_qrcode that reside in the #slide2 div...

I also tried

$('#slide2')find('.rss_qrcode').css('display', 'block');

Didn't work either =(

3 Answers 3

5

You're off by one character in both cases!

$('#slide2 .rss_qrcode').css('display', 'block');
//        ^-- space here means look inside #slide2

OR

$('#slide2').find('.rss_qrcode').css('display', 'block');
//          ^-- dot required for function chaining
1

Try to do this:

$('#slide2 > .rss_qrcode').css('display', 'block');

Learn more about selectors here: http://www.w3schools.com/jquery/jquery_ref_selectors.asp

0

You made it sound complicated while it's not...when you have id it dosen't matter of whose id it's.

So code below is just what you need:

$('#2>.b').css("background-color", "red");

Demo: http://jsfiddle.net/Q6FUM/1/

Before you get into jquery selectors which are mostly css selectors but modified here and there you need to get a hold of css selectors. The link below will get you started on it..

http://www.w3schools.com/cssref/css_selectors.asp

Selectors are just way to select an element in html it could be via class, id, attributes, or heritage ( like the first child of abc div). There are some selectors that are not available but will be in next version of css.

You maybe wondering what is a difference between .class.class vs .class .class, well take a look here, What is the difference between the selectors ".class.class" and ".class .class"?.

2
  • there difference between > vs space between #id .class is that space means inside which could be like div>div>p.class but > means element which is directly child of id #id, has class .class, AND is the direct child of #id.
    – Techsin
    Commented Nov 5, 2013 at 18:07
  • > is for direct children, not looking in all descendants Commented Apr 3, 2021 at 0:16

Not the answer you're looking for? Browse other questions tagged or ask your own question.