for static html page
$("input:checked").addClass("highlight");
works fine . But for ajax populated page its not working.
Is there any better idea how radio box can be highlighted for a开发者_C百科jax pages as well.
After you received the ajax parts, just rerun the command
$("input:checked").addClass("highlight");
should do the job. Or are there any reasons against?
Just put this somewhere before your first AJAX call:
$(function() {
$("body").ajaxSuccess(function () {
$("input:checked").addClass("highlight");
});
});
If you aren't altering their values with JS, then I wouldn't use jQuery at all, just use CSS:
input[checked] { background: red }
Note this CSS selector will not work in IE6.
精彩评论