So i’ve been working, searching, and smacking my head on the table all day over this. I am vary VARY new to all of this so i’m sorry if my coding is incredibly junior. What i’m trying to do is create a mechanism that remembers the anchor url of the current page but then when the user goes to change the nation alters the links in the nations page to bring the user back to exactly where they were but within the new nation directory.
Thus far i’ve gotten the selector pulling the info from the previous page and saving it as a cooky. I even have it altering the urls just as i wanted. The problem is that i gave each of the tags a country code for the name. When the code executes i can’t get it to pull each name and apply it to the bespoke ‘s href as it moves through the page. I’ve only been able to get the first one to select or the last one to witch it applies to all of them. Any insight as to what i’m doing wrong would be awesome.
$('#setNation').click(function(event) {
var fromPage = window.location.pathname
$.cookie("pageFrom", fromPage);
});
$('.nationSelect').each(function() {
$('.nationSelect').attr("herf", "http://domain.com/"+$(this).attr("name")+$.cookie("pageFrom"));
});
And the HTMl Looks like this
<div id="nationList">
<a name="de" class="nationSelect">
<div id="nationListIcon">
<div id="nationListImg" style="background-position: -229px -76px;"></div>
<p lang="de" xml:lang="de">Deutschland</p>
</div>
</a>
<a name="es" class="nationSelect">
<div id="nationListIcon">
<div id="nationListImg" style="background-position: -305px -76px;"></div>
<p lang="es" xml:lang="es">España</p>
</div>
</a>
<a name="fr" class="nationSelect">
<div id="nationListIcon">
<div id="nationListImg" style="background-position: -380px -76px;"></div>
<p lang="fr" xml:lang="fr">France</p>
</div>
</a>
</div>
Thanks for all your help
You have a typo. Its href, not herf. The herf sounds like something you pick up from a dirty girl.