Question

Consider the this example:

HTML:

<input type="radio" name="radio" onchange="init()" value="1" >option1
<input type="radio" name="radio" onchange="init()" value="2">option2

JS:

function init(){
    alert("Arrrr");
}

As you can see, the onchange event doesn't work on a radio input. Which events can I use on a radiobutton? I need some kind of input to change between two states that can actually react on a change.

Was it helpful?

Solution

Check your console, the function was actually not defined before the element.

I modified your fiddle to put the function in the <head>, it works then: http://jsfiddle.net/4ca8a/4/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top