Select A single divide and change it
Hey,
I am having trouble trying to work with this jquery code. It currently looks like this:
-
$(".div2").hide();
$(".div1").hide();
$('a.changeDiv2').click(function(){
$(".div2").hide("slow");
var id = this.id.replace('div2id_', "");
$("#"+id).show("slow");
});
$('a.changeDiv1').click(function(){
$(".div1").hide("slow");
var id = this.id.replace('div1id_', "");
$("#"+id).show("slow");
});
//HTML
<div id="1" class="div1">
A
</div>
<div id="2" class="div1">
B
</div>
<div id="3" class="div1">
C
</div>
<div id="1" class="div2">
A
</div>
<div id="2" class="div2">
B
</div>
<div id="3" class="div2">
C
</div>
The problem is, when a click a link, the first id it comes across with id=i, is the one that is changed. How can set it to change only div2 id 2 when a linked it clicked? And I cannot change the id's because there values are determined by a database.
Thanks!