I'm tried to .append() a new radio type, then if I clicked in new radios, start a new function, but I can't do this. this is my code:
HTML:
<label>Where take the photo?</label>
<input type="radio" id="MX0" name="wherePhoto" value="MX0"> México
<input type="radio" id="EX0" name="wherePhoto" value="EX0"> Foreign
<div id="newPhoto"></div>
<div>
<a class="btn btn-default" onclick="addPhoto();" id="btnAdd">Add photo</a>
</div>
JS:
var id = 1;
function addPhoto() {
var $newPhoto='<div><label>Where take the photo?</label><input type="radio" id="MX' +id+ '"name="wherePhoto' + id + '" value="MX"> México<input type="radio" id="EX' +id+ '" name="wherePhoto' +id+ '" value="EX"> Foreign <div>';
$('#newPhoto').append($newPhoto);
id++;
}
$('[id^=MX]').click(function() {
alert("hello MX");
});
$('[id^=EX]').click(function() {
alert("hello EX");
});
So I try to send a alert when click on the new Radio (MX1)
Thanks to any help