Sure this must've been asked here before but can't find anything.

I have a page with a list of buttons on the left, and a list of divs on the right. Each button has a class that corresponds to the ID of the div. So for example, button one is ".button1" and when clicked, does something to "#div1", ".button2" to "#div2" and so on. If this was my script:

```
$('.button1').click(function(){
    $("#div1").css("color","red");
});
$('.button2').click(function(){
    $("#div2").css("color","red");
});
and so on...

```

...instead of repeating it for every pair, I know I could get the class of the clicked button, check the number on the end, check the div ID's and match it with the corresponding one.

But I don't know how to go about it!