Ok so I admit I am not great with Jquery, I tend to stick with HTML5 and CSS and only mess with JQuery when needed. That said, I know JQuery will solve my current issue but I am not versed in it well enough to know how to do this.
I have a website where I translated each page into spanish as well as english. I have a link inside of an includes that appears on every page with the option to choose either english or spanish. What I would like to do, is set up that link so that it:
A) grabs the link of whatever page they are currently on. So if they were on www.website.com/page1.php it would grab that link
B) append the text "_sp" to the end of the link so that it goes to the spanish version of the same exact page they are on. Therefore when they click the spanish link, in this case, it would take them to www.website.com/page1_sp.php
Currently it just forces them to the homepage in each language, but I think it would be much nicer if it could keep them on the same page but just the other language version of it.
Obviously I could just place the link separately on every page and change the link on every page, but it would be nicer to use jquery so I can just place the link once in the include and still have it pick the correct page.
Thank you for your time.
Ok I did a bit more digging elsewhere and figured it out. For anyone else who might stumble upon this and need it:
<script>
$(function() {
$("#link").attr('href', document.URL.replace(/\.php$/i, '_sp.php'));
});
</script>
Thanks guys for your responses!