Let say i have this code
HTML
<select id="id1">
<option>a</option>
<option>b</option>
<option>c</option>
</select>
<select id="id2">
<option>a</option>
<option>b</option>
<option>c</option>
</select>
<select id="id3">
<option>a</option>
<option>b</option>
<option>c</option>
</select>
<div id="result1"></div>
<div id="result2"></div>
<div id="result3"></div>
Javascript
var i;
for (i = 1; i <= 3; i++) {
$('#id'+[i]).change(function(){
$("#result"+[i]).html('<p>Number</p>'+[i]);
});
}
Different <select> id and different result <div> id through loop
I just want, each <select> tag change, show the result through the div based on the id
Like this:
<select> id1 change to b, then div1 show b
<select> id2 change to c, then div2 show c
<select> id3 change to a, then div3 show a
In my example fiddle, the code i write is not working, can you please help me?
Thank you in advance
selects, register event for that class. Do not use loops to register.change()events.idattribute must be unique