[英]onclick anchor-link auto click element
I want if someone clicks the navigation link "Mediengestaltung" (see picture) that he is scrolling to an anchor and additionally auto-click another id, in this example #design
. 我希望有人单击他正在滚动到锚点的导航链接“ Mediengestaltung”(参见图片),并另外自动单击另一个ID,在此示例中为#design
。 Question is regarding this site: https://bm-translations.de/km.php within the navigation 有关此网站的问题:导航内的https://bm-translations.de/km.php
I tried this, but its crashing the site: 我尝试了这个,但是它使网站崩溃了:
<a href="https://bm-translations.de/km.php/#video" onclick="document.getElementById("design").click();location="https://bm-translations.de/km/#video"">Mediengestaltung</a>
#button
id which is set to the link. #button
id设置为链接。 #design
id which is set to the anchor. #design
ID设置为锚点。 .carousel-selector-1
class to click on to switch to the desired slide .carousel-selector-1
类以单击以切换到所需的幻灯片
$('#button').on('click', function() {
var anchorTag = $("#design");
$('html,body').animate({scrollTop: anchorTag.offset().top},'slow');
$('.carousel-selector-1').click();
return false;
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.