【问题标题】:How to hide #div from href attribute in anchor tag如何从锚标记中的href属性隐藏#div
【发布时间】:2013-12-15 06:47:06
【问题描述】:

我有带有 href 属性的锚标记,例如 <a onclick='loadReview(\"" + strexternalURL + "\");' href='#productName1' 它显示在 URL 中,例如 http://localhost:54986/Dealerlist.aspx#productName1 我想从 URL 中隐藏 #productName1。 我怎样才能做到这一点?

【问题讨论】:

  • 如果您没有在新页面上使用此 id 值,则将其删除并将其留空,或者可以使用 return false
  • -1 提供一点帮助,以便我们了解您想要做什么。您的问题目前没有详细说明,以至于至少有两种可能的解释。 1.你想隐藏#productName1而不重新加载页面。 2. 您想在页面重新加载后隐藏#productName1。请读者怜悯!

标签: javascript jquery html asp.net css


【解决方案1】:

使用 return false 语句。像这样:

<a 
  href='#productName1' 
  onclick='loadReview(\"" + strexternalURL + "\");return false;'
>
  Link
</a>;

【讨论】:

    【解决方案2】:

    像这样格式化你的超链接:

    <a href="urlGoesHere">TextToDisplayGoesHere</a>
    

    【讨论】:

    • 实际上我在 onclick 事件上编写的 loadReview javascript 函数正在重定向到其他页面,然后我必须加载这个 id 为 #productName1 的 div
    猜你喜欢
    • 2015-05-09
    • 2020-07-09
    • 2019-04-03
    • 2012-06-08
    • 2021-11-12
    • 2021-09-23
    • 2011-12-28
    • 2019-11-23
    • 1970-01-01
    相关资源
    最近更新 更多