0

这是html:

<select id="langOptionSet">
      <option value="english">English</option>
      <option value="spanish">Spanish</option>
</select>

这是我为语言更改编写的脚本:

$(function(){
SetSelectedLanguageText();
}); 

var SetSelectedLanguageText = (function ($){
    var language = $("#langOptionSet option:selected").val();
alert(language);
$.ajax({
    url: 'languages.xml',
    success: function(xml) {
        $(xml).find('translation').each(function(){
            var id = $(this).attr('id');
            var text = $(this).find(language).text();
            $("." + id).html(text);
        });
    }
}); 


$("#langOptionSet").change(function() {
SetSelectedLanguageText();
});

但是SetSelectedLanguageText即使在页面加载时也不会触发该功能。这个脚本有什么问题?

谢谢

4

0 回答 0