0
我有這段代碼:當然的JavaScript包括另一個文件
var curState = 'Agenda';
function switchState(newState) {
curState = newState;
}
function Inbox() {
switchState('Inbox');
document.getElementById("u-content").innerHTML = "Currently, you're viewing the Inbox.";
}
function Friends() {
switchState('Friends');
document.getElementById("u-content").innerHTML = "Currently, you're viewing the Friends.";
}
function Agenda() {
switchState('Agenda');
document.getElementById("u-content").innerHTML = "Currently, you're viewing the Agenda.";
}
function List() {
switchState('List');
document.getElementById("u-content").innerHTML = "Currently, you're viewing the Book List.";
}
function News() {
switchState('News');
document.getElementById("u-content").innerHTML = "Currently, you're viewing the News.";
}
function Notes() {
switchState('Notes');
document.getElementById("u-content").innerHTML = "Currently, you're viewing the Notes.";
}
中顯示的文本是一個考驗,我會改變它。關鍵是,我必須在菜單的這些「狀態」中放置大量文本,並且在這裏輸入它並不是非常方便,特別是如果稍後會進行更改。因此,我想知道如何在JavaScript中添加不同形式的文件,或者讓它們使用JavaScript顯示,如* .php文件。
有沒有人知道如何做這樣的事情?我搜索了很多在互聯網上,但無法找到的東西對我有用,除了document.getElementById().innerHTML = "";
答案可能是不只是把一切都放在單獨的文件,但更動態思考和創造的一些功能,可以做多件事情,而不是寫了很多的做功能* *僅一個東西等 – adeneo
我對JavaScript很新,所以你可以更精確一點嗎? –