example <a id = "fb" href= "#">Facebook</a>
Actually i want if page is Arabic it should be like this
href = "www.facebook.com/ar"
if page is English href = "www.facebook.com/en"
Maybe this helps
let lang = document.documentElement.lang;
console.log(lang);
let link = document.getElementById("fb");
if(lang == 'ar'){
link.href += '/ar'
} else if(lang == 'en'){
link.href += '/en'
}
<a id="fb" href= "www.facebook.com">Facebook</a>
<html> tag has a lang attributeYou can try this =>
<html lang="en">
<head>
<title>Document</title>
</head>
<body>
<a id = "ar">Facebook AR</a>
<a id = "en">Facebook EN</a>
<script>
var ar = document.getElementById("ar").setAttribute("href", "www.facebook.com/ar");
var en = document.getElementById("en").setAttribute("href", "www.facebook.com/en");
</script>
</body>
</html>
but it is better to use like this, if not it may be some console errors
var ar = document.getElementById("ar") ? document.getElementById("ar").setAttribute("href", "www.facebook.com/ar") : null;
var en = document.getElementById("en") ? document.getElementById("en").setAttribute("href", "www.facebook.com/en") : null;
/enor/aror its justwww.facebook.com.. Also like I saw in your comment below the href iswebsite.ae/ar/social#https:www.facebook.com/arOR justwww.facebook.com.. And you want this action just to thefbanchor..or you've another hrefs to do the same action with .. Please post the actual code .. and it will be better to show what you've tried so farlang="en"andlang="ar"to your<html>tag??