简体   繁体   English

如何使链接可点击但不能点击?

[英]How to make a link clickable but also not?

So I'm working on my webshop and doing the final points to make it all good looking. 因此,我正在网上商店中进行工作,并做最后几点,以使所有内容都看起来不错。

I thought you know what'd be cool? 我以为你知道会很酷吗? If there was a questionmark which said what you can search for. 如果有问号说您可以搜索什么。 So few seconds later there it was.... but... you can't hover on mobile so I thought. 几秒钟后就出现了....但是...您无法在移动设备上悬停,所以我想。 Cheap fix. 便宜的修复。 make it clickable. 使它可点击。 Which turns out wasn't a cheap fix because if you click on it, it links you to the top of the page. 事实证明这并不是一个便宜的解决方案,因为如果您单击它,它会将您链接到页面顶部。 How do I make it that the popover is clickable, but leads to nowhere and also doesn't refresh the page or annything? 我如何使弹出窗口可单击,但导致无处又无法刷新页面或其他内容?

I got this so far:` 到目前为止,我得到了:

    <form method="GET" action="search.php#shop" class="navbar-form navbar-right">
      <a href="#" title="Zoektermen" data-toggle="popover" data-trigger="focus" data-placement="left" data-content="U kunt zoeken op land, beschrijving, naam en merk."  >
        <p class="fa fa-question"></p>
      </a>
      <input id="form" name="id" type="text" placeholder="Producten zoeken" class="form-control" />
      <button type="submit" class="btn btn-primary">Zoekresultaten tonen</button>
    </form>
</div>

` `

Kinda stuck here so help will be appreciated! Kinda卡在这里,将不胜感激! Thanks in advance PS Don't mind the text. 在此先感谢PS不用理会文字。 It's Dutch :P 这是荷兰语:P

The script is: 脚本是:

<script> $(document).ready(function(){ $('[data-toggle="popover"]').popover(); }); </script>

First give it an id or class 首先给它一个ID或类

<a href="#"  id="popover_button" title="Zoektermen" data-toggle="popover" data-trigger="facous" data-placement="left" data-content="U kunt zoeken op land, beschrijving, naam en merk."  ></a>

Than disable the functionality with jQuery 比禁用jQuery的功能

<script type="text/javascript">
$('#popover_button').click(function(e){
    e.preventDefault();
});
</script>

Add to the <a> nchor: 添加到<a>锚点:

onclick="e.preventDefault();" onclick =“ e.preventDefault();”

or 要么

onclick="return false;"

or 要么

href="javascript:void(0)"

It'd be easier if you provided the actual function being used. 如果提供了正在使用的实际功能会更容易。

 <form method="GET" action="search.php#shop" class="navbar-form navbar-right"> <a href="#" title="Zoektermen" data-toggle="popover" data-trigger="facous" data-placement="left" data-content="U kunt zoeken op land, beschrijving, naam en merk." onclick="e.preventDefault();"> <p class="fa fa-question"></p> </a> <input id="form" name="id" type="text" placeholder="Producten zoeken" class="form-control" /> <button type="submit" class="btn btn-primary">Zoekresultaten tonen</button> </form> 

<a href="#" title="Zoektermen"> My Text</a>

这应该工作正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM