I have the anchor in the HTML page and I want to click on the below anchor only once when the page is loaded but it's not clicking on the anchor element.
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>
I had tried the JQuery as below but it not working
$(document).ready(function () {
$('._5vmb button _p').trigger('click');
});
答案 0 :(得分:4)
选择器错误:
$(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>
&#13;
material = new THREE.MeshPhongMaterial({
color: 0xFF9800,
side: THREE.BackSide,
opacity: 1//0
});
&#13;
答案 1 :(得分:1)
尝试点击事件功能
的文档
$(document).ready(function() {
$('._5vmb.button._p').on('click', function(){console.log('clicked')});
$('._5vmb.button._p').click();
});
&#13;
<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>
&#13;
答案 2 :(得分:1)
不应该
$(document).ready(function() {
$('._5vmb.button._p').trigger('click');
});
如果我正确阅读你的HTML