【问题标题】:displaying different div on navigation tab click, refreshing content, default select tab在导航选项卡单击时显示不同的 div,刷新内容,默认选择选项卡
【发布时间】:2015-10-23 07:23:50
【问题描述】:

我是 asp 和 css 概念的新手,在这里我遇到了一个非常基本的问题

我有一个导航栏 <li><a href = "#Div1" >Division 1</a></li>
<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 在更新面板中定义

提前感谢您期待一些帮助。

【问题讨论】:

    标签: jquery css asp.net


    【解决方案1】:

    似乎唯一的解决方案是使用 javascript。 Rotora 在非常相似的 question 中提到了一个解决方案。

    HIS 解决方案(根据您的用例调整)是

    if (document.location.hash == "" || document.location.hash == "#")
        document.location.hash = "#Div1";
    

    【讨论】:

    • 好的,谢谢,它工作了一点,但不完全。 Art teh page load Div is diplayed 但是当我从导航栏中选择 Div2 然后它首先显示 div1 的一部分,然后在底部 div2。
    • css 文件 : .tab, .tab:target ~ #Div1{ display: none; } #Div1, .tab:target { 显示:块; .tab, .tab:target ~ #Div2{ display: none; } #Div2, .tab:target { 显示:块; }
    • 普通文本框在选择 Div2 时不可见
    猜你喜欢
    • 2022-09-27
    • 1970-01-01
    • 2020-06-16
    • 1970-01-01
    • 2015-03-18
    • 1970-01-01
    • 1970-01-01
    • 2021-05-06
    • 1970-01-01
    相关资源
    最近更新 更多