jQuery と prettyPhoto (wordpress 用プラグイン) の使用に問題があります。私の問題は、既に機能しているタグの外側にある非表示の div から画像の説明を取得したいということです。これは私がこれまでに持っているものです:
<div class="portfolie_short_content_containe">
<a class="lightbox" style="text-decoration: none;" rel="lightbox" href="<?php echo $image[0]; ?>" title="<?php echo $image_desc; ?>">
<span class="hover">
<div class="portfolio_thump_hover_text">
<span class="lable"><?php echo $short_descr;?></span><br>
<span class="lable"><?php echo $link;?></span><br>
<span class="lable"><FONT style="color : #f47b42;">Se CV</FONT></span>
</div>
</span>
<img src="<?php echo $image[0]; ?>" width="<?php echo $image[1]; ?>" alt="<?php echo $image_alt; ?>"></img>
</a>
<!-- hidden div containing description -->
<div id="lightbox" style="display: none"><p><?php echo $full_descr; ?></p><div>
</div>
jQuery.prettyphoto.js ファイルは次のようになります。
theRel = $(this).attr('rel');
galleryRegExp = /\[(?:.*)\]/;
isSet = (galleryRegExp.exec(theRel)) ? true : false;
var x = 500;
var elmtid = $(this).attr('class');
// Put the SRCs, TITLEs, ALTs into an array.
pp_images = (isSet) ? jQuery.map(matchedObjects, function(n, i) {
if ($(n).attr('rel').indexOf(theRel) != -1)
return $(n).attr('href');
}) : $.makeArray($(this).attr('href'));
pp_titles = (isSet) ? jQuery.map(matchedObjects, function(n, i) {
if ($(n).attr('rel').indexOf(theRel) != -1)
return ($(n).find('img').attr('alt')) ? $(n).find('img').attr('alt') : "";
}) : $.makeArray($(this).find('img').attr('alt'));
//Get text from hidden dir!
pp_descriptions = (isSet) ? jQuery.map(matchedObjects, function(n, i) {
if ($(n).attr('rel').indexOf(theRel) != -1)
return ($(n).find('p').text()) ? $(n).find('p').text() : "";
}) : $.makeArray($(this).find('p').text());
私はjQueryの経験がありません。説明を理解するのを手伝ってくれる人はいますか? 私はこのようなことを試しました!
pp_descriptions = (isSet) ? jQuery.map(matchedObjects, function(n, i) {
if($(n).attr('class') != -1)
return ($('#'+elmtid).html()) ? $('#'+elmtid).html() : \"\";
}) : $.makeArray($('#'+elmtid).html());
しかし、うまくいきませんでした。