Я новичок в javascript, и у меня возникли проблемы с использованием метода jQuery "каждый". У меня есть модуль галереи на сайте Joomla, который работает как простой слайдер изображений. Я добавил некоторый код, чтобы включить лайтбокс на связанных изображениях. Что я хотел бы сделать сейчас, так это скопировать заголовок эскиза (который в настоящее время добавляет модуль) в атрибут заголовка в ссылке, чтобы он отображался в лайтбоксе для каждого изображения.
Вот как устроен HTML...
<div class="camera_wrap" id="camera_wrap_106">
<div class="cameraContents">
<div class="cameraContent">
<a class="camera_link" href="lightbox-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="lightbox-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="lightbox-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());
});
Заранее спасибо!