当我单击特定单选按钮时,如何在上下文框中显示图像?如何操作某个单选按钮以在场景框中显示图像?单选按钮由 jquery 和 javascript 制成,而不是 html。任何解决方案或帮助?
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/