Im trying to get all the ids4's from a list of images in a div into an jquery array. This is the html:
<div id = "tdgallerys">
<img id2="/uploads/ssp/album_2/image_10.jpg"
id3="Pic1" id4="1"
src="/uploads/ssp/album_2/thumbnails/image_10.jpg"
rel="scrollers"/>
<img id2="/uploads/ssp/album_2/image_11.jpg"
id3="Pic2" id4="2"
src="/uploads/ssp/album_2/thumbnails/image_11.jpg"
rel="scrollers"/>
<img id2="/uploads/ssp/album_2/image_12.jpg"
id3="Pic3" id4="3"
src="/uploads/ssp/album_2/thumbnails/image_12.jpg"
rel="scrollers"/>
</div>
This is what i am trying:
$(document).ready(function () {
var images = new Array();
var count = 0;
var id = 0;
$("[rel='scrollers']").click(function (event) {
var dvImages = $('#tdgallerys img').attr('id4');
$.each(dvImages , function (i) {
images.push(dvImages);
alert(dvImages);
});
var desc = $(this).attr('id3');
});
});
I put the array outside the click function because i need to access the array from another click function later
$("#next").click(function (event) {
id = id++;
alert(images[id]);
});