I'm trying to automatically click a href
link when the page loads.
<div class="loadmore" kind="rb">
<a href="javascript:;" target="_self">تحميل المزيد...</a>
</div>
The link is supposed to load more comments when you click it.
I tried this:
window.onload = function() {
autoloadmore()
};
function autoloadmore() {
var loadmoreClass = document.getElementsByClassName("loadmore")[0];
var loadmoreChild = loadmoreClass.getElementsByTagName("a");
if(loadmoreClass){
loadmoreChild[0].click();
}
}
but it doesn't seem to work. The problem seems to be with click()
, because when I use other codes such as .style.color
, they work.
I'm using Blogger by the way.
This's a sample blog:
http://blog-sample-001.blogspot.com/2018/09/title.html
(go to تحميل المزيد...)
ps: I can't change the div.
Assign some ID
to <a href="javascript:;" target="_self">تحميل المزيد...</a>
<a href="javascript:;" target="_self">تحميل المزيد...</a>
. For example, clickAfterPageLoad
or whatever you want, and then try this...
$(document).ready(function() {
$("#clickAfterPageLoad").trigger('click');
});
or if you cant't change div
, you can do like this:
$(document).ready(function() {
$(".loadmore a").trigger('click');
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.