rayfidelity wrote:
Hmm the removeclass part doesn't seem to work, when i click on the
other radio button the previous stays red...
On Jun 21, 7:27 pm, Klaus Hartl <[EMAIL PROTECTED]> wrote:
rayfidelity wrote:
Klaus thanks it works!
Since you made a great suggestion, here's the thing
it's like this
<ul>
<li><input type="radio" name="section" value="">bla bla</li>
<li><input type="radio" name="section" value="">bla bla 2</li>
</ul>
i'd actually like to change the background of the list item, so how do
i append the class to the appropriate list item?
Try this:
$(document).ready(function() {
$("[EMAIL PROTECTED]'section']").click(function(){
$(this).parent()[this.checked ? 'addClass' :
'removeClass']('checked');
});
});
li.checked {
background: red;
}
--Klaus
Stupid me, try this:
$(document).ready(function() {
$("[EMAIL PROTECTED]'section']").click(function() {
$(this).parent()[this.checked ? 'addClass' :
'removeClass']('checked').siblings().removeClass('selected');
});
});
No more elegance any longer...
--Klaus