I've made this script for changing some colors on a custom element. My problem is that I can't find a way to localize the links in the href attribute.
Is there an easy way for me to do this?
/* Wilfa Svart Color Change Function */
jQuery(document).ready(function() {
jQuery('.precision-link-color-1').on('click', function(e){
e.preventDefault();
jQuery(".precision-image-link").attr("href", "http://newsite.wilfa.no/produkter/kaffetrakter/svart-presisjon-aluminium/");
jQuery('.wilfa-precision-product-content').css('background', 'url(../wp-content/themes/wilfa/images/coffee-brewer.jpg) no-repeat center center');
});
jQuery('.precision-link-color-2').on('click', function(e){
e.preventDefault();
jQuery(".precision-image-link").attr("href", "http://newsite.wilfa.no/produkter/kaffetrakter/svart-presisjon-sort/");
jQuery('.wilfa-precision-product-content').css('background', 'url(../wp-content/themes/wilfa/images/coffee-brewer-black.jpg) no-repeat center center');
});
});
Specifically, this line:
jQuery(".precision-image-link").attr("href", "http://newsite.wilfa.no/produkter/kaffetrakter/svart-presisjon-sort/");
UPDATE
Here's my attempt with an else/if statement to get the lang attr(This works):
/* Wilfa Svart Color Change Function */
jQuery(document).ready(function() {
var theLanguage = jQuery('html').attr('lang');
jQuery('.precision-link-color-1').on('click', function(e){
e.preventDefault();
if(theLanguage == 'en-US') {
jQuery(".precision-image-link").attr("href", "http://alternative-link.com/");
} else {
jQuery(".precision-image-link").attr("href", "http://original-link.com/");
}
jQuery('.wilfa-precision-product-content').css('background', 'url(../image.jpg) no-repeat center center');
});
jQuery('.precision-link-color-2').on('click', function(e){
e.preventDefault();
if(theLanguage == 'en-US') {
jQuery(".precision-image-link").attr("href", "http://alternative-link.com");
} else {
jQuery(".precision-image-link").attr("href", "http://original-link.com");
}
jQuery('.wilfa-precision-product-content').css('background', 'url(../image.jpg) no-repeat center center');
});
});