How this jQuery function works [closed]

1

I'm wondering how this function works. It has function of when someone by the iphone click on the link it does not stay in exist and yes direct to link.

demo.autoclick = function() { 
    $('a').on('tap', function(e) {
        var el = $(this);
        var link = el.attr('href');
        window.location = link;
    });
} 
    
asked by anonymous 30.08.2017 / 18:02

1 answer

3

Reading the jQuery mobile documentation :

  

tap event Description : Triggered after a quick,

That is, it is an event that works for mobile as the click works for the browser. Internally it listens to touchstart and touchend and that there was touchmove to make sure that it is just a tap ("tap") in some element.

Then within this callback the this is the clicked element. Then the code fetches the href attribute of that element and redirects the page to that url.

    
30.08.2017 / 18:13