【问题标题】:How to find anchor link within anchor tag and click on that link automatically using jquery如何在锚标记中找到锚链接并使用 jquery 自动单击该链接
【发布时间】:2015-01-08 12:22:20
【问题描述】:

如何在锚标签中找到锚链接并在jquery中自动点击该链接。

例子

<div id="myid">
<a id="interestingness" href="htttp://mylink.com">mytestinglink</a>
</div>

【问题讨论】:

  • 在所有兼容 HTML5 的浏览器上,您只需使用:interestingness.click();

标签: javascript jquery


【解决方案1】:

你可以试试这样的:

$('#interestingness')[0].click();

【讨论】:

    【解决方案2】:
    <div id="myid">
    <a id="interestingness" href="htttp://mylink.com" target="_blank">mytestinglink</a>
    </div>
    


    $("#interestingness").click(function(){
              var currentAnchor = $(this);
              alert(currentAnchor.text());
              alert(currentAnchor.attr('href'));
            });
    

    【讨论】:

      【解决方案3】:

      $('#interestingness').click();

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2020-08-02
        • 1970-01-01
        • 1970-01-01
        • 2013-03-31
        • 1970-01-01
        • 2021-05-16
        • 2017-05-28
        相关资源
        最近更新 更多