嘿伙计们,如果选中此单选按钮则显示此“div”,我可以使用什么功能来表示。
提前致谢。
HTML
<form id='form-id'>
<input id='watch-me' name='test' type='radio' /> Show Div<br />
<input name='test' type='radio' /><br />
<input name='test' type='radio' />
</form>
<div id='show-me' style='display:none'>Hello</div>
jQuery
$('#form-id').change(function() {
if ($('#watch-me').attr('checked')) {
$('#show-me').show();
} else {
$('#show-me').hide();
}
});
您可以在这里看到它的实际效果:http://jsfiddle.net/wmKGd/
更新 25.01.2013
从 jQuery 库 1.8.x 升级到 1.9.x 后
请使用代替
jQuery 库 1.8.x
jQuery('#some-id').attr('checked')
jQuery 库 1.9.x
jQuery('#some-id').prop('checked')
您可以在此处查看更新后的脚本的运行情况:http://jsfiddle.net/9XXRY/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)