I am running the following code as I am trying to get each .fotorama
id first and then assign each of them as each .nav
link href.
$(".fotorama").each(function(){
id = $(".fotorama", this).data("id");
$(".nav li a").attr("href", '#'+ id);
});
This is giving me #undefined
to each .nav
link tho
How should I do to set same href as each .fotorama
id?
html, just an example, ids and menu items are dynamically generated on the site*
<ul class="nav">
<li><a href=" "></a></li>
<li><a href=" "></a></li>
<li><a href=" "></a></li>
</ul>
<div class="fotorama" id="p1"></div>
<div class="fotorama" id="p2"></div>
<div class="fotorama" id="p2"></div>
var n = 0;
$(".fotorama").each(function(){
id = $(this).attr("id");
$(".nav li a:eq(" + n + ")").attr("href", '#'+ id);
n++;
});