Show/Hide href link 点击按钮

Show/Hide href link on click on a button

在按钮上单击会生成详细信息页面。 单击它时,我有一个 href link,它会在页面中导航。 但是在页面加载时应该只有按钮(点击它生成主页)但是 href link 也出现了。

我希望在页面加载时应该只有一个按钮,通过单击它应该出现 href link。 并且在单击另一个按钮时应该消失。

脚本:

$(document).ready(function () {
        $('#priorityC').hide();
        $('#perC').hide();
        });
    $('#btnAnalyse').click(function () {
        $('#priorityC').show();
        $('#perC').show();
    });

这是按钮:

<asp:ImageButton ID="btnAnalyse" runat="server" OnClick="btnAnalyse_Click"/>

这是我只想在单击上面的按钮时显示的 href link:

<a href="Homepage.aspx#perC">Hourly Detailed Priority Representation</a>
<a name="priorityPer">
<div id="perC" class="center">
<asp:Label ID="lblDPTC" runat="server" Text="Detailed Percentage     representation of Ticket Count" Visible="false"></asp:Label>
</div>
</a>

它在页面加载时隐藏但在单击按钮时不显示。

您可以将 href link 写在 div 中并使用 Jquery,您可以相应地隐藏和显示 div。

代码片段

<script>
// On load hide the div
$(document).ready(function(){
  $('#MYDIV').hide();
};

// call this function on button click to show/hide the link
function showHideLink(buttonName)
{
  if(buttonName=='blah')
  {
    $('#MYDIV').hide();
  }
  else
  {
    $('#MYDIV').show();
  }
}
</script>

希望对您有所帮助。

<asp:ImageButton ID="btnAnalyse" runat="server" ImageUrl="image1.jpg" OnClick="btnAnalyse_Click"/>


<a href="Homepage.aspx#p" id="linkid" runat="server">Hourly Detailed Priority Representation</a>
<a name="priorityPer">
<div id="per" class="center">
<asp:Label ID="lblDPTC" runat="server" Text="Detailed Percentage     representation of Ticket Count" Visible="false"></asp:Label>
</div>
</a>

并在您的后端页面上(codepage.cs)

 protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        linkid.Visible = false;
    }
}
protected void btnAnalyse_Click(object sender, ImageClickEventArgs e)
{
    if (linkid.Visible == false)
    {
        linkid.Visible = true;
    }
}

 protected void btnAnother_Click(object sender, EventArgs e)
    {
     linkid.Visible = false;
    }

test.aspx

<li class="nav-item">
   <a class="nav-link" id="AdminFaciliy" href="charts.html" runat="server">
   <i class="fas fa-fw fa-user">
</i>

text.aspx.cs

if (Utype.Trim().ToUpper()=="ADMIN"){               
  AdminFaciliy.Visible = true;
}