我是 asp 和 css 概念的新手,在这里我遇到了一个非常基本的问题
我有一个导航栏
<li><a href = "#Div1" >Division 1</a></li><br/>
<li><a href = "#Div2">Division 2</a></li>
我有如下划分
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<div id = "TextBox">
//a text box here which is common and should be displayed with both the sections below
</div>
<div id ="Div1" class= "section">
// some button and text boxes here
</div>
<div id ="Div2" class= "section">
// some button and text boxes here
</div>
</updatePanle>
CSS文件:
.section { display:none }
.section:target { display: block }
css 文件部分定义有助于正确选择分区,但当页面加载时,仅显示顶部的 TextBox div。
所以我需要在页面加载时默认显示 div1 内容,当 TextBox div 中的文本框被一个值填充时,内容刷新并且页面上再次没有 div1 或 div2 内容。
div 在更新面板中定义
在此先感谢您的帮助。
最佳答案
似乎唯一的解决方案是使用 javascript。 Rotora在一个非常相似的 question 中提到了一个解决方案.
HIS 解决方案(根据您的用例调整)是
if (document.location.hash == "" || document.location.hash == "#")
document.location.hash = "#Div1";
关于jquery - 在导航选项卡上显示不同的 div 单击,刷新内容,默认选择选项卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33288581/