I'm new to jQuery.. I have the following html div containing several links, each with several data attributes
<div class="image-gallery">
j = 0;
@foreach (var image in @Model.Images)
{
<a class="secondary-img" href="..." data-img-sq-nr="@j" data-colorID="@image.ColorId" ... >
<img .../>
</a>
j++;
}
</div>
In a jQuery script, I need to find the element with a particular data-colorID
and get its data-img-sq-nr
, I was trying something like this, but this obvisousy doesn't work
var seq = $('.image-gallery a[data-colorID='some-other-variable'].attr(data-img-sq-nr));
any help is much appreciated, thanks