Problem with .each() and coloring labels...

Problem with .each() and coloring labels...

Hello,

I am having a problem a jQuery function I am working on.  I want the function to scan all the inputs on a page, and if any are checked, set the corresponding labels bold.

Here's a working example:  Click Here
Also here's my code pasted directly:

  1. <!DOCTYPE HTML>
  2. <html lang="en-US">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title></title>
  6. <script type="text/javascript" src="http://www.aurorafxstudios.com/_global/includes/jQuery/jquery-1.5.1.min.js"></script>
  7. <script type="text/javascript">
  8. function setStyles() {
  9. $("input:checked").each(function(i) {
  10. inputId = $(this).attr("id");
  11. $('label[for="'+inputId+'"]').style.fontWeight="bold";
  12. });
  13. }
  14. $(document).ready(function(){
  15. $("#test5").attr('checked', true);
  16. setStyles();
  17. });
  18. </script>
  19. </head>
  20. <body>
  21. <form>
  22. <input id="test1" type="checkbox" checked="checked"><label for="test1">Test 1</label><br>
  23. <input id="test2" type="checkbox"><label for="test2">Test 2</label><br>
  24. <input id="test3" type="checkbox" checked="checked"><label for="test3">Test 3</label><br>
  25. <input id="test4" type="checkbox"><label for="test4">Test 4</label><br>
  26. <label for="test5">Test 5</label><input id="test5" type="checkbox"><br>
  27. <label for="test6">Test 6</label><input id="test6" type="checkbox"><br>
  28. </form>
  29. </body>
  30. </html>
Anyone have any advice as to what I am doing wrong?

Thank you!
Jesse