简体   繁体   English

模拟来自另一个内部页面上的链接的点击

[英]Simulate a click from a link on another internal page

I have four images with links on my main page . 我的主页上有四个带有链接的图像。 I also have four matching galleries on another page that are hidden except for one at a time. 另一个页面上 ,我也有四个相匹配的画廊,它们一次都被隐藏了。 Each gallery is shown when a specific image on that gallery page is clicked. 单击该图库页面上的特定图像时,将显示每个图库。

I am trying to get the home page images to link specifically to their corresponding galleries (such as clicking on the children image on the home page, will loadup the gallery page and display the children gallery). 我正在尝试使主页图像专门链接到其相应的画廊(例如,单击主页上的子图像,将加载图库页面并显示子画廊)。

I read these questions and tried to implement their answers: 我阅读了以下问题,并尝试实现它们的答案:

https://stackoverflow.com/questions/2847185 https://stackoverflow.com/questions/2847185

https://stackoverflow.com/questions/7047746 https://stackoverflow.com/questions/7047746

The gallery page loads up using a carousel plugin and a custom script for my setup was created to allow the images/tabs(the class is img.imgslide and they do not have any ID property) on the carousel to show/hide galleries: 图库页面使用轮播插件加载,并为我的设置创建了一个自定义脚本,以允许轮播上的图像/标签(类为img.imgslide,并且没有任何ID属性)显示/隐藏画廊:

jQuery(document).ready(function() {
        if (jQuery('.customtabs > br').length) {
            jQuery('.customtabs > br').remove();
        }       
});

function displaycustom_tab(obj) {
        var totalSlides = jQuery(obj).parent().find('>div').length / 3;
        var tabi = 0;
        var slidei = jQuery(obj).index() + 1;
        if (slidei > (2 * totalSlides)) {
            tabi = slidei - (2 * totalSlides);
        } else if (slidei > (totalSlides)) {
            tabi = slidei - totalSlides;
        } else {
            tabi = slidei;
        }
        tabi--;
        jQuery('.customtabs > div').removeClass('activetab');
        jQuery('.customtabs > div:eq(' + tabi + ')').addClass('activetab');
    jQuery(window).trigger('resize');
}

I tried to use this code: The text wrapped with *s is my added code (with the *s). 我尝试使用此代码:用* s包裹的文本是我添加的代码(使用* s)。

jQuery(document).ready(function() {
        if (jQuery('.customtabs > br').length) {
            jQuery('.customtabs > br').remove();
        }       
        ****jQuery('#newborn').get(0).click();****
});

I get this error in Chromes Inspect panel : 在Chrome检查面板中收到此错误

gallery.js:5 Uncaught TypeError: Cannot read property 'click' of undefined gallery.js:5未捕获的TypeError:无法读取未定义的属性“ click”

I'm not sure how to get this working. 我不确定如何使它正常工作。 Do I need to create an attribute property for the ID field on the carousel tabs? 我是否需要为轮播标签上的ID字段创建属性属性?

Looked through the source of the link you posted. 浏览了您发布的链接的来源。 Looks like you might be using the wrong ID. 看起来您可能使用了错误的ID。

jQuery('#newborn').get(0).click();

should be 应该

jQuery('#newbornlink').get(0).click();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM