0
我有一個腳本,它將圖像url轉換爲路徑,並且可以在主節點導航上正常工作以使圖像淡入淡出。下面的腳本給我:使用JQuery替換ASP.NET中的圖像url的一部分
http://localhost/Bar/App_Themes/main/images/Beers-Faded.gif
一旦我瀏覽一個節點更深它增加了應用程序路徑的url和函數失敗:
http://localhost/bar/Bar/App_Themes/main/images/Beers-Faded.gif
的jQuery:
$(function() {
$('img.fade').each(function() {
var $$ = $(this);
var target = $$.css('background-image').replace(/^url|["]|[\)\(]/g, '');
$$.wrap('<span style="position:relative;"></span>')
.parent() // span elements
.prepend('<img>')
.find('img:first') // selector now new image
.attr('src', target);
console.log(target);
$$.css({
'position': 'absolute',
'left': 0,
'top': this.offsetTop
});
$$.hover(function() {
$$.stop().animate({
opacity: 0
}, 250);
}, function() {
$$.stop().animate({
opacity: 1
}, 250);
});
});
});
圖片:
<img class="fade" runat="server" src="~/App_Themes/main/images/Beers-Color.jpg" style="background-image: url('../Bar/App_Themes/main/images/Beers-Faded.gif');" />`
你能幫我找到我爲了適應網站地圖導航而改變的部分代碼嗎?我的網站只能進入三層深度。
非常感謝,
詹姆斯。
感謝您整理格式尼克:) – 2010-06-29 20:16:26