Delaying a href Actions Using jQuery |
X

Congrats, You are Subscribed to Receive Updates.

Delaying a href Actions Using jQuery


Delaying a href Actions Using jQuery.Some urgent moment, we need to delaying the a href actions. Here i have the code snippet to delay the actions.  First we need to stop the action by using the “preventDefault”  or Stop Propagation function.  As like the following one.

$('a#kvcodes').click(function (e) { // Here mine a href action is triggered
    e.preventDefault();    // Stop Execution 
});

Than retrieve the a href url using the following one

 var kv_to_url = this.getAttribute("href"); // anchor href url

Now, you can delay the action by using the  ” setTimeout”  function. The following code snippet will explain you.

 setTimeout(function(){
         window.location = kv_to_url;
    },2500);

So, the above codes total compilation, here

$('a#kvcodes').click(function (e) { // Here mine a href action is triggered
    e.preventDefault();    // Stop Execution 

    var kv_to_url = this.getAttribute("href"); // anchor href url

    setTimeout(function(){
         window.location = kv_to_url;
    },2500);      
});

That’s it. if you have any doubt or problem with it comment below, i will help you.

commenter

About Varadharaj V

The founder of Kvcodes, Varadharaj V is an ERP Analyst and a Web developer specializing in WordPress(WP), WP Theme development, WP Plugin development, Frontaccounting(FA), Sales, Purchases, Inventory, Ledgers, Payroll & HRM, CRM, FA Core Customization, PHP and Data Analyst. Database Management Advance Level

Comment Below

Your email address will not be published. Required fields are marked *

*

Current ye@r *

Menu

Sidebar