我有這http://jsfiddle.net/TtX7F/1/但我不知道如何讓它在周圍工作。 HTML部分工作,但js只在編輯時才起作用,而不是在發佈的時候,而且我不知道應該在CSS中放置什麼。將代碼添加到周圍
這是JavaScript
$("input").on("click", color);
$(document).ready(color);
function color() {
var shell = $("[name='shell']:checked").val(),
thumbs = $("[name='thumbs']:checked").val(),
result = {
"shell": "",
"thumbs": ""
};
switch (true) {
case (shell === "black"):
result.shell = "http://liberatedinamerica.com/wp-content/uploads/2013/05/shell-black.png";
break;
case (shell === "blue"):
result.shell = "http://liberatedinamerica.com/wp-content/uploads/2013/05/shell-blue.png";
break;
case (shell === "pink"):
result.shell = "http://liberatedinamerica.com/wp-content/uploads/2013/05/shell-pink.png";
break;
}
switch (true) {
case (thumbs === "red"):
result.thumbs = "http://liberatedinamerica.com/wp-content/uploads/2013/05/ey-thumbs-ps3-red.png";
break;
case (thumbs === "lime"):
result.thumbs = "http://liberatedinamerica.com/wp-content/uploads/2013/05/ey-thumbs-ps3-lime.png";
break;
}
$(".shell").attr("src", result.shell);
$(".thumbs").attr("src", result.thumbs);
console.log(result);
}