我有这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);
}