单选(radio)按钮点击事件

代码:
<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;
}
});
原文地址:https://www.cnblogs.com/muhy/p/13685681.html