Reputation: 29
I have the following HTML code. I just need to make a tag un-clickable after the first click.
<li>
<a class="active orig-a" href="/webizdropship/adminhtml_createorder/?sku=<?php echo base64_encode(urlencode($this->getProduct()->getSku())); ?>&qty=1">
<?php echo $this->__('Add to cart') ?>
</a>
</li>
I tried the code below:
jQuery('orig-a').click(false)
The disabled
property also didn't work. jQuery one
didn't help. When I'm clicking on a
tag, its button, it has href
and it sends results as much as I click on this tag. Page is loading for a long time.
If I click on it, server responds for about 30 seconds and with jQuery I need to don't send on click again on that address, otherwise it adds quantity as much as I click on it.
Upvotes: 0
Views: 447
Reputation: 18973
You can set off click for a tag or use one click
$("#test").click(function(){
console.log('clicked');
$(this).off('click');
})
Use one click
$( "#onetest" ).one( "click", function( event ) {
console.log('one clicked');
});
$("#test").click(function(){
console.log('clicked');
$(this).off('click');
})
$( "#onetest" ).one( "click", function( event ) {
console.log('one clicked');
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<a href="#" id="test">Test disable</a>
<br>
<a href="#" id="onetest">Test One Click</a>
Upvotes: 0