2

我使用此代码创建链接以下载一些项目:

<div class="main-item-custom-form">
<input type="radio" name="iCheck_211" id="PDF" value="1853"> <label for="user-type">PDF</label>
<input type="radio" name="iCheck_211" id="EPUB" value="2531"> <label for="user-type">EPUB</label>
</div>
<div class="free-buttons">
<div id="good-1853" class="down_goods" style="display:none;"><a href="/download_file/subitem/1853" class="btn btn-block btn-default"><i class="fa fa-download"></i>&nbsp;&nbsp;download  (915.54 kB)</a></div>
<div id="good-2531" class="down_goods" style="display:none;"><a href="/download_file/subitem/2531" class="btn btn-block btn-default"><i class="fa fa-download"></i>&nbsp;&nbsp;download  (259.58 kB)</a></div>
</div>

使用这个 javascript 代码

$('.main-item-custom-form .iradio_square:first-child').addClass('checked');
    $('.free-buttons .down_goods:first-child').removeAttr('style');
    $('[name^=iCheck_]').on('ifClicked', function (e) {
        $('.down_goods').hide();
        $("#good-"+$(this).val()).show();

    });

选中第一个单选按钮并显示第一个链接。当我选择另一个单选按钮时,它会显示另一个链接。但只有当我在页面上有一组单选按钮时它才能正常工作。任何人都可以帮我编写多个组的代码吗?

4

0 回答 0