2010-07-22 99 views
0

這是希望我今天的最後一個問題:P。jquery屬性rel是搞砸了所有的東西

我有。不同圖像的照片每一個。 HTML代碼波紋管:

<div class="photo"><!-- Start Photo --> 
<div class="transparency"></div> 
    <div class="performer"><p><? echo $perf; ?></p></div> 
    <a href="<?php the_permalink(); ?>" class="jquery" rel="<? echo ''.$perf.''; ?>"><img src="<? echo ''.$pic.''; ?>" width="180" height="135" alt="<? echo ''.get_the_title().''; ?>" style="display:block"/></a> 
</div><!-- End Photo --> 

這是我的jQuery代碼所做的:當我將鼠標懸停照片DIV,它加載Flash影片。當我懸停在該div上時,我想要顯示最初的照片。

這裏是我的jQuery代碼:

$(".photo").hoverIntent(function() { 
    $(this).html('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,24,0" width="100" height="100"><param name="movie" value="http://static.awempire.com/flash/live_feeds/live_feed.swf" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="flashvars" value="appletroot=http://static.awempire.com/flash/live_feeds/&appletskin=template8/template01.swf&appletcol=900000&psid=ddany23&campaign_id=20520&pstour=t1&psprogram=REVS&site=jsm&flags=137438953473,137438953504,1,32&lp_lang=auto" /><embed src="http://static.awempire.com/flash/live_feeds/live_feed.swf" width="100" height="100" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" flashvars="appletroot=http://static.awempire.com/flash/live_feeds/&appletskin=template8/template01.swf&appletcol=900000&psid=ddany23&campaign_id=20520&pstour=t1&psprogram=REVS&site=jsm&flags=137438953473,137438953504,1,32&lp_lang=auto"></embed></object>'); 
}, function() { 
    $(this).html('' + $(".jquery").attr("rel") + ''); 
}); 

的問題是,在相對不與每個圖像corespond。我的意思是,它得到了相對眼前的.photo格,將它們混合,等等......很奇怪

它應該工作,我應該有相對coresponding到它自己的.photodiv。 :(

回答

0

製造ID的工作是這樣的:

$(".photo").hoverIntent(function() { 
    $(this).html('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,24,0" width="100" height="100"><param name="movie" value="http://static.awempire.com/flash/live_feeds/live_feed.swf" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="flashvars" value="appletroot=http://static.awempire.com/flash/live_feeds/&appletskin=template8/template01.swf&appletcol=900000&psid=ddany23&campaign_id=20520&pstour=t1&psprogram=REVS&site=jsm&flags=137438953473,137438953504,1,32&lp_lang=auto" /><embed src="http://static.awempire.com/flash/live_feeds/live_feed.swf" width="100" height="100" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" flashvars="appletroot=http://static.awempire.com/flash/live_feeds/&appletskin=template8/template01.swf&appletcol=900000&psid=ddany23&campaign_id=20520&pstour=t1&psprogram=REVS&site=jsm&flags=137438953473,137438953504,1,32&lp_lang=auto"></embed></object>'); 
}, function() { 
    $(this).html('' + $(this).attr("title") + ''); 

}); 

一聲照片div的標題來代替。

0

$(".jquery").attr("rel")翻譯給我jquery類的元素,並獲得rel屬性,可是你有沒有分配任何類圖像。我想說檢查生成的HTML內容,看看它是否是正確的。

1

$(".jquery").attr("rel")將獲得從第一元素與一流「的jquery」的rel屬性(出整個文檔的),你想從當前塊的.jquery元素,這將是相對

$(".jquery", $(this)).attr("rel") 

或全部:

$(this).html('' + $(".jquery", $(this)).attr("rel") + ''); 
+0

謝謝你,聽起來像它應該工作,但現在我得到undefined,而不是rel值 – webmasters 2010-07-22 20:07:03