I created my check box dynamically in my page. i want to add click event for all checkboxes that dynamically created.
here is my code.
<div data-role="fieldcontain">
<fieldset data-role="controlgroup" id="br">
</fieldset>
</div>
i dynamically created checkboxes and append to fieldset.
$.getJSON("http://localhost/WebSite/",
function(data){
var branchOp="";
$.each(data.branch, function(i,item){
branchOp += '<input type="checkbox" name="branch" id="'+item.branchCode+'" value="'+item.branchCode+'" class="branch"><label for="'+item.branchCode+'">'+item.branchName+'</label>';
$(item.branchCode).addClass("intro");
});
$('#br').append(branchOp).trigger( "create" );
});
i use on(), live(), deligate() method to add event handlers on check boxes.
$('#br').delegate('click','input:checkbox', function(event) {
alert('selected');
});
$('#br').on('click','input:checkbox', function(event) {
alert('selected');
});
nothing is working for me...