html页面:
<input type="radio" name="sex" value="female">female <input type="radio" name="sex" value="male">male
js部分代码:
$(document).ready(function() { $(\'input[type=radio][name=sex]\').change(function() { if (this.value == \'female\') { console.log("female"); } else if (this.value == \'male\') { console.log("male"); } }); });