jquery判断radio选中与否来显示或隐藏某个div

来源:互联网 发布:centos wifi不可用 编辑:程序博客网 时间:2024/05/25 01:35

定义一个函数来判断这个radio是否被选中,方法是通过jq的选择器得到这个被checked的radio的值,如果没被选中,则为null啦,然后if分支,去显示隐藏某个div。


function issetshoplist_theme2() {var value0 = $('input:radio[value=shoplist_theme2]:checked').val();if(value0 != null) {$('#theme2set').show();}else {$('#theme2set').hide();}}

然后,每个radio的click事件发生后,function函数体后执行上面那个函数,显示隐藏某个div。

$("input[name=shoplist_theme]").click(function(){var value = $('input[name=shoplist_theme]:checked').val();$("#iframe2").attr("src","__ROOT__/index.php/Home/Index/ShopList/theme/" + value);issetshoplist_theme2();});

ps:在$(document).ready时也要调用一下这个函数喔···

0 0