JQuery Auto点击 Tag is not working
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JQuery Auto点击 Tag is not working相关的知识,希望对你有一定的参考价值。
我在html页面中有锚点,我只想在页面加载时点击下面的锚点,但它没有点击锚点元素。
HTML
<a aria-label="Options" class="_5vmb button _p" data-ft="{"tn":"p"}" data-hover="tooltip" data-tooltip-content="Options" data-tooltip-position="below" href="#" role="button" id="js_28" aria-controls="js_9y"></a>
我曾尝试过如下JQuery,但它不起作用
$(document).ready(function () {
$('._5vmb button _p').trigger('click');
});
答案
选择器错误:
(document).ready(function() {
$('._5vmb button _p').trigger('click');
});
它应该是:
$(document).ready(function() {
$('._5vmb.button._p').trigger('click');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<a aria-label="Options" class="_5vmb button _p" data-ft="{"tn":"p"}" data-hover="tooltip" data-tooltip-content="Options" data-tooltip-position="below" href="#" role="button" id="js_28" aria-controls="js_9y">a tag</a>
另一答案
不应该
$(document).ready(function() {
$('._5vmb.button._p').trigger('click');
});
如果我正确地阅读你的HTML
另一答案
尝试点击事件功能
以下是click function的文档
$(document).ready(function() {
$('._5vmb.button._p').on('click', function(){console.log('clicked')});
$('._5vmb.button._p').click();
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a aria-label="Options" class="_5vmb button _p" data-ft="{"tn":"p"}" data-hover="tooltip" data-tooltip-content="Options" data-tooltip-position="below" href="#" role="button" id="js_28" aria-controls="js_9y"></a>
以上是关于JQuery Auto点击 Tag is not working的主要内容,如果未能解决你的问题,请参考以下文章
django is not a registered tag library.
django.template.exceptions.TemplateSyntaxError: ‘staticfiles‘ is not a registered tag library.
is not a registered tag library. Must be one of:
selenium+python自动化96-执行jquery报:$ is not defined
Actionscript Error: declaration must be contained within the <Declarations; tag, since it is not