Password: ForumTesting
Hello, I’m currently using the Portfolio Hover page template strictly to change the background when hovering over a link, as this is the only way I’ve managed to achieve this effect so far. However, I'd like each link to redirect to an external page in a new tab, rather than redirecting to the standard internal portfolio pages in the same tab.
I’ve managed to accomplish this with JavaScript using the code below, but it's extremely tedious and will get messed up when adding or changing the order of the list.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<script>
//Project One
document.querySelector("#sections > section > div.content-wrapper > div > div > div > div.portfolio-hover-items > ul > li:nth-child(1) > a").setAttribute('href', 'https://www.facebook.com/');
//Project Two
document.querySelector("#sections > section > div.content-wrapper > div > div > div > div.portfolio-hover-items > ul > li:nth-child(2) > a").setAttribute('href', 'https://www.youtube.com/');
//Project Three
document.querySelector("#sections > section > div.content-wrapper > div > div > div > div.portfolio-hover-items > ul > li:nth-child(3) > a").setAttribute('href', 'https://www.amazon.com/');
//Project Four
document.querySelector("#sections > section > div.content-wrapper > div > div > div > div.portfolio-hover-items > ul > li:nth-child(4) > a").setAttribute('href', 'https://x.com/');
var all_links = document.querySelectorAll('a');
for (var i = 0; i < all_links.length; i++){
var a = all_links[i];
if(a.hostname != location.hostname) {
a.rel = 'noopener';
a.target = '_blank';
}
}
</script>
Is there a better way to do this?
Thanks!