Browser-friendly way to simulate anchor click with jQuery?

前端 未结 4 1709
一整个雨季
一整个雨季 2021-01-01 06:32

I\'m trying to simulate a click on an anchor tag using jQuery. I\'ve been digging around StackOverflow and Google for a while and haven\'t found anything that works on all o

4条回答
  •  轮回少年
    2021-01-01 06:54

    I use this approach. Seems to work okay.

    $(function() {
        fireClick($("a"));
    });
    
    function fireClick (elem) {
        window.location = $(elem).attr('href');
    }
    

提交回复
热议问题