[英]Loading a page Click the Anchor tag
Hi friends I am trying many ways to onloading the page click the anchor tag using jquery or JavaScript. 嗨,朋友们,我正在尝试多种方法来加载页面,并使用jquery或JavaScript单击定位标记。
must see the rel attribute . 必须看到rel属性。
<div id="local">
<a id="fmp-button" href="#" rel="http://google.com">
click
</a>
</div>
<script>
//$('#fmp-button').trigger('click');
//$("a[href='#']").click();
//$('#fmp-button').click();
//$('#fmp-button')[0].click();
//$(function(){
// window.location.href = $('#fmp-button').attr('href');
//});
</script>
I am tried all the ways Any one help me how to click the anchor tag when time of page loading anchor tag must be rel attribute 我已经尝试过所有方法有人在页面加载锚标签的时间必须为rel属性时如何帮助我单击锚标签
如果您只想更改页面,则可以这样做:
window.location = $('#fmp-button').attr('rel');
I think you need to do 我认为你需要做
<div id="local">
<a id="fmp-button" href="http://google.com">
click
</a>
</div>
<script>
$(function(){
$('#fmp-button').click();
});
</script>
here's another way... 这是另一种方式
<div id="local">
<a id="fmp-button" href="#" rel="http://google.com">click</a>
</div>
<script src="//code.jquery.com/jquery.js"></script>
<script>
$(document).on('click', '#fmp-button' ,function() {
var url = $('#fmp-button').attr('rel');
window.location.replace(url);
});
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.