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...
...ペアごとに繰り返すのではなく、クリックされたボタンのクラスを取得し、最後の番号を確認し、div ID を確認して、対応するボタンと一致させることができることを知っています。
しかし、私はそれについて行く方法がわかりません!