I have this markup:
- <!-- FRAME ONE -->
- <fieldset>
- <legend class="some_class">Anbefales</legend>
- <input type="radio" />
- <span>Visa/MasterCard.</span>
- <div>Some text:
- <b class="pink">BOLD PINK TEXT</b>
- some text.</div>
- </fieldset>
- <!-- FRAME TWO -->
- <div class="final_radio">
- <input type="radio" />
- Some text
- </div>
There are two radio buttons, sometimes one will be disabled, other times the other will be disabled. I would like to make a script that:
First: Changes the color of surrounding text of the disabled radio button to the color grey.
Second: Checks the other radio button.
This was my plan: I would make a script that:
First: Removes all the current classes and add the class "greyed_out" (or better: change only the color of) the parent element, all siblings and children of siblings (if any) of the radio button that is disabled at that time.
Second: Sets the attribute "checked to the other radio button".
I made a script, but when I set the
bottom radio button to disabled
the script doesn't work:
- <script type="text/javascript">
- $(document).ready(function(){
- $(':radio[disabled="false"]').attr('checked', true);
- $(':radio[disabled="true"]').siblings().addClass('greyed');
- $(':radio[disabled="true"]').siblings().contents().removeClass().addClass('greyed');
- });
- </script>
Also, is there a way to avoid writing this for each line of code?:
- $(':radio[disabled="true"]')
Thank you for your time.
Kind regards,
Marius