$(function () {
$("#staying_hide").click(function(){
if($(this).attr("checked")){
$("#staying1").show();
$("#staying2").hide();
}else{
$("#staying2").show();
$("#staying1").hide();
}
});
});
$("#staying_hide").click(function(){
if($(this).attr("checked")){
$("#staying1").show();
$("#staying2").hide();
}else{
$("#staying2").show();
$("#staying1").hide();
}
});
});
function f(){console.log(this.checked);
$('#staying1')[this.checked?'show':'hide']();
$('#staying2')[!this.checked?'show':'hide']();
}
f.call($(':checkbox').change(f)[0]);
</script>
好像代码不全吧?
show
hide
在哪里?
<head>
<title>Index</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="http://cloud.xing-xing.com/jquery.js"></script>
<style>
</style>
</head>
<body>
<table>
<tr>
<th>숙박요청 <input type="checkbox" id="staying_hide" name="staying_hide" value="1" ></th>
<td id="staying1" name="staying1" style="display:none;" >
<input type="radio" name="staying" value="male" /> asdf
<input type="radio" name="staying" value="female" /> qwer<br />
</td>
<td id="staying2" name="staying2" style="display:block;" >
</td>
</tr>
</table>
</body>
<script>
$(function () {
$("#staying_hide").click(function(){
if($(this).attr("checked")){
$("#staying1").show();
$("#staying2").hide();
}else{
$("#staying2").show();
$("#staying1").hide();
}
});
});
</script>
</html>