-6
function show(page) {
var html = "";
switch (page) {
    case "home":
        html = 'All the stuff of the page  ';
        break;
    case "about":
        html = 'All the stuff of the pahe';
        break;
    case "contact":
        html = "This is the contact page<br />...";
        break;
}

document.getElementById('container').innerHTML = html;
}

http://jsfiddle.net/z2UCX/5/

「about」リンクは about に、「contacts」リンクは連絡先に移動します。1 つのリンク/ボタン/画像のみを使用してこれを機能させる方法。1 つのボタンがすべてを循環します。ここでは、「ホーム」リンクの代わりに「左ボタン」を使用してみましょう。リンクを無限に循環し続ける必要があります。

4

2 に答える 2

1

基本的なカウンターを使用できると思います。何かのようなもの:

var cnt = 0;
function show() {
  var html = "";
  switch (cnt) {
    case 0: html = "All the stuff of the page "; break;
    case 1: html = "All the stuff of the page"; break;
    case 2: html = "This is the contact page<br />..."; break;
  }
  document.getElementById("container").innerHTML = html;
  cnt = (cnt+1)%3;
}

次に、リンクで、この関数を呼び出します。show();

于 2013-08-01T16:05:30.233 に答える