Reputation: 4271
This method does not work because checkbox is not in the DOM:
$('input[type=checkbox][name=rememberme]').prop('checked', true);
I don't know how to use .on() because I do not need to bind event:
$(elements).on( events [, selector] [, data] , handler );
How to checked checkbox which is loaded thru ajax using jQuery?
Upvotes: 4
Views: 1364
Reputation:
$( document ).ajaxComplete(function() {
$('input[type=checkbox][name=rememberme]').prop('checked', true);
});
Try this:
Upvotes: 5
Reputation: 100205
try doing like, on your ajax response, get the checkbox and set it to checked, like:
var cBox = $($.parseHTML(your_ajax_response_data)).filter("input[name='rememberme']");
cBox.prop('checked', true);
Upvotes: 1