开发者

how to highlight checked radio using jquery

开发者 https://www.devze.com 2023-01-15 07:51 出处:网络
for static html page $(\"input:checked\").addClass(\"highlight\"); works fine . But for ajax populated page its not working.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号