【问题标题】:jQuery content slider with RELATIVE links带有相对链接的 jQuery 内容滑块
【发布时间】:2023-04-02 13:26:01
【问题描述】:

我有一个以前工作的网站,它使用一个小的 jQuery 脚本来触发带有类内容幻灯片的图像,以便在滚动时进行动画处理,并在单击时显示包含内容的 div,并在再次单击时隐藏等等,这在我的主页(例如:index.html)但不适用于我的子目录页面(例如:subdir/code/howcssworks.html),我假设这是由于相对链接路径不再有效。

这里是 jQuery 脚本。

$(document).ready(function() { 

var slideState = "closed";

$('div.content').hide();

$('img.contentslide').click(function() {
    $('div.content').toggle(1500,function() {
        if (jQuery.browser.msie) {                          // Lines 15-17 = special treatment for IE, because of  
            this.style.removeAttribute('filter');           // lack of support for ClearType font rendering on items
        }                                                   // being toggled in jQuery.
    });
        if (slideState == 'closed') {
            $('img.contentslide').attr('src','images/website/hidecontentstd.png');
            slideState = "open";    

        } else {
            $('img.contentslide').attr('src','images/website/showcontentstd.png');
            slideState = "closed";
        }
});

$('img.contentslide').hover( function() {
    if (slideState == 'closed') {
        $( this ).attr('src','images/website/showcontenthvr.png');

    } else {
        $( this ).attr('src','images/website/hidecontenthvr.png');
    }
},
function() {
    if (slideState == 'open') {
        $( this ).attr('src','images/website/hidecontentstd.png');

    } else {
        $( this ).attr('src','images/website/showcontentstd.png');
    }
}
);

return false;   // If JS is disabled - show extra content automatically 

});

我的问题是:如何更改 jQuery 脚本中的相对链接路径,使其在我网站的主页面和子页面上都能正常工作?

【问题讨论】:

    标签: jquery html hyperlink dreamweaver relative-path


    【解决方案1】:

    而不是这样的链接:

    images/website/hidecontentstd.png
    

    你需要这个:

    /images/website/hidecontentstd.png
    

    假设您的 images 文件夹位于 yoursite.com/images

    【讨论】:

      猜你喜欢
      • 2023-03-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-13
      • 2011-12-07
      相关资源
      最近更新 更多