0

Ok I have an issue getting my label to change upon a radio button being selected. The following code works just fine for what I need:

http://jsfiddle.net/8ypCV/

<table> not present

However, if I place the same code between table attributes like I need to, all of a sudden the code does not work. I have tried giving the table a name/id/class and addressing the css to that but still nothing. I just need to know what Im missing to get this code to work with in a table. Here is the link to the fiddle with the table attribute:

http://jsfiddle.net/5g62v/ <table> present

user258122
  • 39
  • 2
  • 7

1 Answers1

3

It's not working because your CSS uses the adjacent sibling selector (+) This means that only elements that are direct siblings will be selected. Try moving your label elements into the same table cell in order for your existing CSS to work.

fiddle: http://jsfiddle.net/dDVBq/

Dryden Long
  • 10,072
  • 2
  • 35
  • 47
  • Thank you, yeah I found that out, however is there a work around if they are in different columns. The only reason why I ask is because at work we have to use a program that creates certain html docs and there is no way to tell it to place them within the same td. I would have to manually going into every file and remove the td separators on each row and each table. Thats why I would either like to find a css work around or even a javascript work around that I can add in using a header file. – user258122 Apr 08 '14 at 20:52
  • If you can use javascript then this should get you started: http://stackoverflow.com/questions/1423777/how-can-i-check-whether-a-radio-button-is-selected-in-javascript – Dryden Long Apr 08 '14 at 20:57
  • Ok looked through it, since Im not all that familiar with JS for this particular issue I went with something simple like: if $('input[id=T2_1]:checked') {'label[for=T2_1]'.border:2px.solid.red!important} this didn't work either would you be able to let me know what I might be missing in it? – user258122 Apr 08 '14 at 21:08
  • @user258122 I'd post a new question for that – Dryden Long Apr 08 '14 at 21:13