我已經爲每個javascript添加了一個元素和文本。有了這個代碼:Javascript:更改文本取決於選擇值
$(document).ready(function() {
if ($('welcome_page').length) {
$('#my_element').after('<tr><td><td><td id="welcome_message">Welcome to my page</td></td></td</tr>');
}
});
我需要能夠將文本>可喜的變化,以我的<頁取決於在頁面設置語言:
<select id="languages" onchange="submit();">
<option value="1" selected="">English</option>
<option value="2">Spanish</option>
<option value="3">French</option>
</select>
我已經試過這一點,但它不這樣的伎倆:
function langChoice(sel){
var langChange = document.getElementById('languages');
var langOption = document.getElementById('welcome_message');
if (sel.options[sel.selectedIndex].value == "1") {
langOption.innerHTML = "Enter price per month";
}
else if (sel.options[sel.selectedIndex].value == "2") {
langOption.innerHTML = "Enter price per week";
}
else if (sel.options[sel.selectedIndex].value == "3") {
langOption.innerHTML = "Enter price per day";
}
else if (sel.options[sel.selectedIndex].value == "4") {
langOption.innerHTML = "Enter for sale hour";
}
}
如果你打電話給你?功能 – 2014-11-20 22:55:58
您可以添加一個重新啓動並重現問題嗎? – AlvinJ 2014-11-20 22:56:49