selecting all title attributes that are the same as link ID

selecting all title attributes that are the same as link ID

hi!

i'm a newbie to js scripting. I have no idea whether and how the following might be possible:

main question:
can I work with variables in jQuery selectors?

I have 5 links with different HTML-IDs on my page. and there are about 75 pictures with HTML titles from one of the 5 link groups. the name of the link IDs match the 5 possible title attributes for images.

if I click on a link, I want to make fancy jQuery stuff with all the images that have a title with the same name as the IDs.

the code template: ;)

my noob-ask-query would be as follows:


var matchingname = $("a").attr("title");
  $(matchingname).click(function () {
      $(".matchingname").eq.hide();
      return true;
    });



surprise, surprise: doesnt work. how would it work?

thanks!