문제

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.

도움이 되었습니까?

해결책

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/

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top