我有一個需要被翻譯爲每個語言jQuery的查找和替換多個項目
像這樣每月表(顯然不工作)
$('.lang-en #monthly th').each(function() {
var text = $(this).text();
$(this).text(text.replace('Tam', 'Jan'));
$(this).text(text.replace('Hel', 'Feb'));
$(this).text(text.replace('Maa', 'Mar'));
$(this).text(text.replace('Huh', 'Apr'));
$(this).text(text.replace('Tou', 'May'));
$(this).text(text.replace('Kes', 'Jun'));
$(this).text(text.replace('Hei', 'Jul'));
$(this).text(text.replace('Elo', 'Aug'));
$(this).text(text.replace('Syy', 'Sep'));
$(this).text(text.replace('Lok', 'Oct'));
$(this).text(text.replace('Mar', 'Nov'));
$(this).text(text.replace('Jou', 'Dec'));
$(this).text(text.replace('Yht', 'Total'));
});
看起來很好,你是不是明顯的意思是'顯然不工作? – Sarfraz
你說「顯然不工作」,怎麼樣?爲什麼這不工作?這段代碼片段有什麼意義? –
作爲@client的附註,考慮緩存'$(this)',這是最好的做法。 –