<input type="radio" name="regenerate" value="1" id="cus" />
<input type="radio" name="regenerate" value="2" id="gen" />
<input type="checkbox" name="renerateEmail" id="renerateEmail" />
<div id="txt" style="display:none"><input type="pa开发者_StackOverflow中文版ssword" name="pass" id="pass" /><br />
<input type="password" name="repass" id="repass" /></div>
i want to hide and show the div "txt" when radio button has the value 1 , how can i do that.
maybe this
$("input[name=regenerate]").click(function(){
if($(this).val() == 1) {
$("#txt").show();
} else {
$("#txt").hide();
}
});
You request isn't clear. Do you want to hide the div when the radio button is 1 and show it when it's 2? Or what?
You want something like:
if ($("#cus:checked").length == 1) {
$("#txt").show();
}
"hide and show".. "has the value 1" - ?not precisely clear what you want but .. here's one way
$(':radio[name=regenerate]').click(function() {
if ($(':radio[name=regenerate]:checked').val() == 1)
$('#txt').show()
else
$('#txt').hide();
})
精彩评论