tags:

views:

53

answers:

2

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 ajax pages as well.

+2  A: 

After you received the ajax parts, just rerun the command

$("input:checked").addClass("highlight");

should do the job. Or are there any reasons against?

hacksteak25
+1  A: 

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.

Doug Neiner