views:

3036

answers:

1

I'm using the rel attribute to match a div to a button. I use the button's id in the corresponding div's rel field. There are multiple buttons. When a button is clicked I want to show the corresponding div with the show() method, and to hide the other divs. The buttons work fine, but the divs are not responding. My gut says I'm not formatting the selector properly. Thanks.

    $("div.media_button").click(function (){

   var relid = this.id;

   $("div.media_button").not(this).fadeTo("normal",0.33);
   $(this).fadeTo("normal",1);
   $("div.media_selection[rel!='" + relid + "']").hide();
   $("div.media_selection[rel='" + relid + "']").show();   
 });
+3  A: 

You do not need the single quotes. Can you paste the markup just incase the below doesnt end up working.

$("div.media_selection[rel=" + relid + "]").hide();
$("div.media_selection[rel=" + relid + "]").show();
redsquare
That shouldn't be the problem though, quotes won't break the selector, they're just not needed. Welcome to 10k btw!
karim79
ty karim, it was a shot in the dar...I have seen the quotes screw things up before, as I mentioned the markup would help!
redsquare
Bet you the button ID does not exactly match the div rel attributes :)
karim79
I'm thinking you're right, Karim :)
Jonathan Sampson
:) yup..that is the odds on fav
redsquare
That being said, are **div[rel='abc'].media_selection** and **div.media_selection[rel='abc']** treated the same way by jQuery?
Jonathan Sampson
should be the same yeah
redsquare
http://pastebin.me/f6d877e3462f512e158681107e876f6d
redsquare