代碼:
<div id="radio-button-div" style="display: inline;">
<fieldset data-role="controlgroup" data-type="horizontal" style="text-align: center; height: 50px;">
<input type="radio" name="radio-choice-h-2" id="radio-choice-h-2a" value="camera1" >
<label id="radio-camera1-label" for="radio-choice-h-2a">Camera 1</label>
<input type="radio" name="radio-choice-h-2" id="radio-choice-h-2b" value="camera2" checked="checked">
<label id="radio-camera2-label" for="radio-choice-h-2b">Camera 2</label>
</fieldset>
</div>
點擊事件:
$("input[name=radio-choice-h-2]").click(function(){
switch($("input[name=radio-choice-h-2]:checked").attr("id")){
case "radio-choice-h-2a":
alert(“click camera1");
break;
case "radio-choice-h-2b":
alert(“click camera2");
break;
default:
break;
}
});