HTML

<p>
    <input id="list"  onclick="acheck1()" type="radio" name="list" value="1">选项1 
    <input id="list"  onclick="acheck2()" type="radio" name="list" value="2">选项2
</p>
<p class="box1"  style="display:none">点击第一个显示这里</p>
<p class="box2"  style="display:none">点击第二个显示这里</p>

JS

function acheck1(){
    $(".box1").show();
    $(".box2").hide();
}
function acheck2(){
    $(".box2").show();       
    $(".box1").hide();
}
$(function(){
    var list = $('#list:checked').val();
    if( list == 1){
        $(".box1").show();
    }
    if( list == 2){
        $(".box2").show();
       }
});

转载:https://blog.csdn.net/kaxixiaozheng/article/details/103125119
参考:https://blog.csdn.net/qq_44275894/article/details/111689856

标签: layui

添加新评论