JavaScript Highlighting html element when radio button is checked w/o js highlighting html element

I would like to know if there is a way to modify an html item (i.e. a div) when a radio button is selected without using js. Here is the markup:

<div class="container">
    <input id="myRadioBtn" class="btn-radio" type="radio" name="name" value="value"/>
    <div class="box">BOX</div>
</div>

I would like for "box" to change its color once "myRadioBtn" is selected. I know I could use js/jQuery but if possible, I'd like to do it in CSS only. Is that possible?

Answer:1
#myRadioBtn:checked + .box {
    background-color:red;
}

http://jsfiddle.net/tyEys/

I'm not able to check if it works in IE8.

Edit: You could replace the + with a ~ to select only the .box that comes immediately after the radio. So if you had 2 boxes after the radio, the second one won't be affected.

Answer:2

I was trying the following: f.addEventListener('submit',(function(frm){ var func = (function(e){somefunction(e,frm);})(e); })(f),false); But this is failing. I want to pass the form (f) as a static ...

I was trying the following: f.addEventListener('submit',(function(frm){ var func = (function(e){somefunction(e,frm);})(e); })(f),false); But this is failing. I want to pass the form (f) as a static ...

  1. javascript passing event as parameter
  2. javascript passing event to function
  3. javascript passing event
  4. javascript passing event onclick
  5. javascript onclick event passing parameters
  6. javascript passing parameters to event handlers
  7. javascript passing this to event handler
  8. javascript passing arguments to event handlers

so, I came across a bug and thought it was interesting. Once I sat and thought about it for 5 seconds, it made sense but curious how one would get past it in the future. so, I have some hashes set up ...

so, I came across a bug and thought it was interesting. Once I sat and thought about it for 5 seconds, it made sense but curious how one would get past it in the future. so, I have some hashes set up ...

i have hiddentfield whose value is changing on javascript. I just wanted to fire serverside event valuechanged event of hiddenfield when its value changed from javascript. I tried with : ...

i have hiddentfield whose value is changing on javascript. I just wanted to fire serverside event valuechanged event of hiddenfield when its value changed from javascript. I tried with : ...

  1. fire server side event from javascript asp.net
  2. fire server side event from jquery
  3. fire server side event from javascript
  4. how to fire server side event for html checkbox
  5. fire server side click event from javascript
  6. how to fire server side event on click of the button
  7. event doesn't fire server side

I want to add a custom attribute for each object in my canvas. I did that using: fabric.Object.prototype.toObject = (function (toObject) { return function () { return fabric.util.object....

I want to add a custom attribute for each object in my canvas. I did that using: fabric.Object.prototype.toObject = (function (toObject) { return function () { return fabric.util.object....

  1. fabricjs custom attributes
  2. fabricjs add custom attributes