cant get an id
cant get an id
i create some code in a div of my site by external php script like this:
-
$.post("myscript.php", function($data){
if($data.length >0) {
$('#mydiv').html($data);
}
});
thats not a problem, i can see the code like this:
-
<input id="myid-1" class="myclass" type="text" value="" name="myid-1"/>
<input id="myid-2" class="myclass" type="text" value="" name="myid-2"/>
<input id="myid-3" class="myclass" type="text" value="" name="myid-3"/>
now i would like to get the id of a clicked element like this:
-
$(document).ready(function(){
$(".myclass").click(function() {
var currentId = $(this).attr('id');
alert("Selected ID: "+currentId);
});
});
but it doesn't work, what am i do wrong?