Let me clear some of this HTML!
There is a violin - Link to the script!
- Put some custom tags
- Remove the closing
</input> that are not valid. Allow yourself to close them to make them beautiful (although this is not required if you are not using XHTML). - Remove the
<ul> which seems superfluous when we can sprinkle some CSS to fit your form elements. - Rename these classes to something more relevant!
HTML
<div id="root"> <input name="buttonState" id="enable" class="action" type="radio" /> <label for="enable">Enable</label> <input name="buttonState" id="disable" class="action" type="radio" /> <label for="disable">Disable</label> <input type="button" class="button" value="Button" /> </div>
JQuery
So, you want to turn on the button when the power button is pressed and off when the power button is pressed? Here:
$('#disable').click(function () { $('.button').attr('disabled', true); }); $('#enable').click(function () { $('.button').attr('disabled', false); });
Finally, CSS.
.action { display: block; float: left; clear: left; margin: 0 10px; } label { display: block; margin: 10px 0; } .button { background: #00F; margin: 0 10px 10px 10px; } .button:disabled { background: #F00; } input, label { cursor: pointer; }
Lovely :)
misterManSam
source share