js实现两个radio按钮,选择不同的radio,input框出现不一样的placeholder提示
html
<label><span style="color:red">* </span>性别</label>
<input class="i-checks" type="radio" name="radio" value="1" id="radio1" checked="checked"/>
<label for="radio1">男</label>
<label style="margin-left: 20px;">
<input class="i-checks" type="radio" name="radio" id="radio2" value="2" />
<label for="radio2">女</label>
</label>
js
$(function () {
$(".i-checks").each(function () {
$(this).on('ifChecked',function(){
if (this.checked) {
if ($(this).attr("id") == "radio1"){
$('#card_num').attr('placeholder', '男孩子');
}
if ($(this).attr("id") == "radio2"){
$('#card_num').attr('placeholder', '女孩子');
}
}
})
})
})

浙公网安备 33010602011771号