0

特定のラジオ ボタンをクリックしたときに、コンテキスト ボックスに画像を表示するにはどうすればよいですか? 特定のラジオ ボタンを操作して、シーン ボックス内に画像を表示するにはどうすればよいですか? ラジオ ボタンは、html ではなく jquery と javascript で作成されています。解決策やヘルプはありますか?

function initialize() {
    var initialScene = getScene("scene1");
    displayScene(initialScene);
}

function changeScene(selectedOption) {
    var selectedSceneId = selectedOption.value;
    var selectedScene = getScene(selectedSceneId);
    if (selectedScene == "scene6") {
        $("#content").effect(
            {
                effect: "explode",
                duration: 1000,
                complete: function () {
                }
            });
    }
    else {
        $("#content").effect(
            {
                effect: "fade",
                duration: 1000,
                complete: function () {
                    displayScene(selectedScene);
                    $("#content").effect("fade", 1000);
                }
            });
    }
}


function displayScene(scene) {
    $("#sceneTitle").html(scene.title);
    $("#sceneText").html(scene.text);
    $("#sceneOptions").html(createSceneOptions(scene));
}

function getScene(sceneId) {
    var matchedScenes = $.grep(scenes, function (scene) {
        return scene.id == sceneId;
    });

    return matchedScenes[0];
}

function createSceneOptions(scene) {
    var sceneOptions = "";
    $.each(scene.options, function (index, option) {
        sceneOptions += "<input type=\"radio\" name=\"options\" value=\"" + option.nextSceneId + "\" id=\"" + index + "\" onclick=\"changeScene(this)\"><label for=\"" +  index   +  "\">" + option.text + "</label><br/>";
    });

    return sceneOptions;
}

私のラジオボタンはjqueryで構成されているため、ラジオボタン用に持っている唯一のhtmlは

<div id="sceneOptions">

フィドル: http://jsfiddle.net/QCN8S/1/

4

1 に答える 1