所以我做了一个显示/隐藏脚本来打开和关闭被点击的元素。但现在我无法让它以某种方式工作,我不知道为什么。
有人可以试试看吗?
HTML
<div id="fleresvar" class="fleresvar"> <u><b>Klik her for at se flere svar</b></u>
<div id="txtmore" class="txtmore" style="display:none;">
<div id="txtask1" style="text-decoration:underline;color:#8F8F8F;cursor:pointer;"></div>
<div id="txtask2" style="text-decoration:underline;color:#8F8F8F;cursor:pointer;"></div>
<div id="txtask3" style="text-decoration:underline;color:#8F8F8F;cursor:pointer;"></div>
<div id="txtask4" style="text-decoration:underline;color:#8F8F8F;cursor:pointer;"></div>
<div id="txtask5" style="text-decoration:underline;color:#8F8F8F;cursor:pointer;"></div>
</div
JavaScript
$("#fleresvar").click(function () {
var $element = $(this);
if ($(this).hasClass('open')) {
$element.removeClass("open");
$element.children(".txtmore").hide(500);
} else {
$(".open").removeClass("open");
$('.txtmore').hide(500);
$element.toggleClass('open');
$element.children('.txtmore').toggle(500);
}
});