gpt4 book ai didi

javascript - 单选按钮隐藏和显示问题

转载 作者:行者123 更新时间:2023-11-27 23:47:53 25 4
gpt4 key购买 nike

我试图通过选择不同的单选按钮来更改内容。我的代码似乎不起作用。有什么问题吗?这是 FIDDLE :

HTML

   <div id="category-table" style="display: block;">
<div class="btn-group" data-toggle="buttons" style="float:right;">
<label class="btn btn-show-category active">
<input type="radio" name="options" id="option1" autocomplete="off" value="A-categories" checked=""> A Categories
</label>

<label class="btn btn-show-category">
<input type="radio" name="options" id="option2" autocomplete="off" value="B-categories"> B Categories
</label>
</div>

<br><br>
<div class="all-categories">
<div class="content-header">Category A</span></div>
</div>

<div class="used-categories" style="display:none;">
<div class="content-header">Category B</span></div>
</div>

</div>

JS

$(document).ready(function () {
$('input[type="radio"]').click(function () {
if ($(this).attr("value") == "A-categories") {
$(".used-categories").hide();
$(".all-categories").show();
}
if ($(this).attr("value") == "B-categories") {
$(".all-categories").hide();
$(".used-categories").show();
}
});
});

有什么建议吗?

最佳答案

enter image description here

只需检查 fiddle 。看起来你没有包含 jquery js 文件。

关于javascript - 单选按钮隐藏和显示问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28845691/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com