这是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
。这个脚本出了什么问题?
感谢