如何更改图库中项目的颜色

时间:2013-07-14 03:43:58

标签: css wordpress

我在点击不同的颜色按钮时试图找出如何更改颜色的项目。

有点像以下网站

http://www.imprintablefashion.com/cgi-bin/brand/site.w?location=olc/cobrand-product.w&category=3&prb=&srb=&mill=&shade=&color=&product=8398&frames=no&target=main&sponsor=004974&nocache=77902

我正在使用WordPress。如果有人能指出我正确的方向,这将是伟大的。任何

示例的想法将不胜感激。

1 个答案:

答案 0 :(得分:0)

你实际上需要有几张图片。每次按项目/按钮,您都会将HTML中图像占位符中的图像更改为所需图像。

// JS
function changeImg()
{ 
    // some logic like swicth to select the image
    document.getElememtById("image_cont").innerHTML = "<img src='" + some_image + "'/>";
}
// Html
<div id="image_cont"></div>
<button onclick="changeImg()">Change the Image</button>

// so on

然后你可以在你的函数中使用一些逻辑来选择你想要的图像。