On a project, I try to change the content of every markup with attribut data-mlid. I have the first part of my code but no way to find how to go further. I'm stuck... I hope you'll be able to help me.
- Loop on every markup with a particular attribut
- Parse XML to find back the associated language
Javascript
$(document).ready(function(){
var lan = "fr" ;
var multilan ;
$.ajax({
url: 'xml/multilan.xml',
success: function(xml){
$("[data-mlid]").each(function(){
$(xml).find($(this).data("mlid")).each(function(){
//What to do now?? How to find the multilan text back?
});
$(this).text(multilan);
})
}
});
});
HTML
<h2 class="stb-text-center" data-mlid="0001"></h2>
XML
<?xml version="1.0" encoding="utf-8"?>
<translations>
<multilan id="0001">
<en>Welcome!</en>
<fr>Bienvenue !</fr>
</multilan>
</translations>
Thank you!
No comments:
Post a Comment