Another suggestion, add a class to the links you want to click only once, and when the links with that class are clicked, check for a particular property. If it exists, cancel the event, if it does not, just add that property to the element.
See the example below, the first link will only work the first time, the second it does not change the scroll bar, while the second continues working normally:
$(".1click").click(function(e) {
var $this = $(this);
if ($this.prop('jaClicou')) {
console.log('ja clicou');
e.preventDefault();
} else {
console.log('1 click')
$this.prop('jaClicou', true);
}
});
$("a").click(function() {
console.log('click');
var total = $("#total").html();
console.log(total);
$("#total").html(parseInt(total) + 1);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><divclass="container">
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<p>O primeiro link só funciona no primeiro clique, o segundo é normal e funciona sempre. Os outros eventos adicionados aos links funcionam normalmente, como o evento para contagem de cliques.</p>
<ul><li><a href="#" class="1click">Só pode haver um clique</a></li></ul>
<ul><li><a href="#">Clique o quanto quiser</a></li></ul>
<p>Total de cliques: <span id="total">0</span></p>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
</div>
I also put in Codepen, which I think is better to see and do some tests:
link