jquery selector

Hi

Im trying to create a onclick event that targets an element, grabs its id and uses that id to target an element with the same class. However, it doesnt work - any ideas?

function is:

$("#partners .item").click(function(){
  var el = $(this).attr("id");
  console.log($("."+el));
  $("."+el).addClass("visible");
});
coolispaulAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GaryCommented:
The code works fine, we need the html as well to debug
http://jsfiddle.net/FR8HE/
0
coolispaulAuthor Commented:
Hi Garyc123

That's odd . example of mine is here:
https://dl.dropboxusercontent.com/u/35928349/Facilities%20Collective/HTML/index.html

if you click the image logos under "partners"  it should display a sepererate area but it doesnt seem to work..

Thanks
0
Chris StanyonWebDevCommented:
You need to be a little clearer in your explanation. 'It doesn't work' is not very helpful. Does the click work, do you get the console output, does the .item actually have an ID.

As Gary says, there's nothing wrong with the code you've posted but it has no context, so we're left guessing!
0
Chris StanyonWebDevCommented:
Sorry - cross posted there :)

Your code is working but it looks like there is no elemet to add the class to. Say you click on an item with an ID of item5, you code will try and add a class to an element with a class of item5, but there are none on your page.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
coolispaulAuthor Commented:
blimey - as easy at that!

Thanks guys i didnt even spot that - called it "text1", "text2" etc instead of "item1..."


Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.