gpt4 book ai didi

javascript - 防止在隐藏和显示时推送元素 - jQuery

转载 作者:行者123 更新时间:2023-11-28 07:40:02 24 4
gpt4 key购买 nike

我在点击图例时隐藏和显示 fieldset 中的内容。

JSFIDDLE示例

 var legends = document.getElementsByTagName("legend");

for(var i=0; i<legends.length; i++)
{
legends[i].onclick = function()
{
var myDivs = this.parentNode.getElementsByTagName("div");
var myDiv;

if(myDivs.length > 0)
{
var myDiv = myDivs[0];

if(myDiv.style.display == "")
{
myDiv.style.display = "none"
}
else
{
myDiv.style.display = "";
}
}
}
}

如何在显示内容后阻止推送?在我的示例中,示例内容在显示内容后被下推。如何重叠div内容?

最佳答案

如果您使用 jquery,我建议在弹出窗口中显示它。在 html 中尝试此代码并确保引用 jquery mobile:

<a href="#popupBasic" id="tet" data-rel="popup"><legend>One Legend</legend></a>

<div data-role="popup" id="popupBasic">
<fieldset>

<div>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.e</div>

</fieldset>
</div>
<div><text>Sample Content</text></div>

jsfiddle:https://jsfiddle.net/UHn6q/51/

关于javascript - 防止在隐藏和显示时推送元素 - jQuery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30995180/

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