Аз съм начинаещ в javascript и имам известни проблеми с използването на метода „each“ на jQuery. Имам модул за галерия на сайт на Joomla, който функционира като обикновен плъзгач за изображения. Добавих някакъв код, за да разреша лайтбокс върху свързаните изображения. Това, което бих искал да направя сега, е да копирам надписа на миниатюрата (който модулът добавя в момента) към атрибута Title във връзката, така че да се показва в лайтбокса за всяко изображение.
Ето как е структуриран HTML...
<div class="camera_wrap" id="camera_wrap_106">
<div class="cameraContents">
<div class="cameraContent">
<a class="camera_link" href="/bglightbox-large.jpg" title="This is where i need the caption"></a>
<div class="camera_caption">
<div>This is the caption</div>
</div>
</div>
<div class="cameraContent">
<a class="camera_link" href="/bglightbox-large.jpg" title="This is where i need the caption"></a>
<div class="camera_caption">
<div>This is the caption</div>
</div>
</div>
<div class="cameraContent">
<a class="camera_link" href="/bglightbox-large.jpg" title="This is where i need the caption"></a>
<div class="camera_caption">
<div>This is the caption</div>
</div>
</div>
</div>
I've gotten the code this far, but it only copies the first caption div to each title attribute rather than executing it on each instance. Not sure if this is even the best start...
$("#camera_wrap_106 .cameraContent").each(function() {
$("#camera_wrap_106 a.camera_link").attr('title', $("#camera_wrap_106 .camera_caption div").html());
});
Благодаря предварително!