0
當我單擊特定的單選按鈕時,如何在我的上下文框中顯示圖像? 如何操作某個單選按鈕以在場景框內顯示圖像?單選按鈕由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/
請撥打小提琴嗎? – bjb568
http://jsfiddle.net/Brannan2/QCN8S/...我的外部jquery代碼似乎不工作jfiddle。不知道它是否會幫助 – 2Truth
感謝您修理小提琴tymeJV。任何幫助?文字是白色的,因爲我有背景圖片。但除此之外, :) – 2Truth