3
我有一个以前工作的网站,使用一个小的jQuery脚本来触发图像与类内容幻灯片动画滚动时,并显示包含内容时单击和隐藏在单击时再次等。,这在我的主要页面中工作得很好(例如:index.html
),但在我的子目录页面上不起作用(例如:subdir/code/howcssworks.html
),并且我认为这是由于相对链接路径不再有效。jQuery内容滑块与RELATIVE链接
这里是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脚本相对连结路径所以它可以正确处理两者的主要网页和我的网站的子页面?