Getting id of clicked div and using it.

Getting id of clicked div and using it.

Hi,

I'm using the top z-index plugin which works fine using this:

*$("#name").click(function(){
        $("#name2").topZIndex();
    });

However, I have many divs on the page that act as triggers for the divs that have their z-index changed and I'm trying to write a function that will work for for them all.

All of the triggers have the same class "trigger", they all each have their own id. Each of these triggers has a corresponding div which is targeted using the plugin, these have the same id as the trigger with the addition of the number "2" after them.

So for example the trigger div <div class="trigger" id="name"> is clicked to change the z-index of the corresponding div <div id="name2">.

In theory I could write a function that says when any div with the class of trigger is clicked, get the id of this div, then change the z-index of the div that has the same id but also with the suffix of "2".

I've tried to write this myself but can't get it to work.

Can anyone help out?

I'm guessing it might start something like this:

    $(".trigger").click(function(){
        var currentId = $(this).attr('id');


Many thanks.