大家好,您如何点击此链接/按钮我无法使用任何方法,我尝试过:
$('btn btn-large btn-info btn-embossed').children('a').click();
$('visit-trigger').trigger('click');
document.querySelector("visit-trigger").click();
我已经尝试了所有名称和类,我不仅可以找到:visit-trigger类。
Website if you want to try your self
<div class="expandable ng-scope" ng-include="entryMethodView(entry_method)">
<form class="entry_details compact-box form-compact ng-pristine ng-valid ng-scope" name="entryDetailsForm">
<div class="form-compact__content center">
<div class="form-compact__part">
<p>Click here to ensure you are subscribed:</p>
</div>
<div class="form-compact__part">
<p class="visit-trigger">
<a class="btn btn-large btn-info btn-embossed" ng-href="https://youtube.com/user/videochumstube?sub_confirmation=1" rel="noopener" target="_blank" href="https://youtube.com/user/videochumstube?sub_confirmation=1">
<i class="fa fa-youtube"></i>
Subscribe here
</a>
</p>
</div>
</div>
答案 0 :(得分:2)
visit-trigger
是一个类,所以使用类选择器
$('.visit-trigger').trigger('click');
//-^-------here
或
$('.btn-embossed').click(); // to fire the click event of `a`
无论如何,最重要的部分是使用适当的选择器。对于类.
,对于ID为#
等等。