我正在尋找JS/jQuery的方式做以下操作 1:與一個'無'圖像並排顯示一系列的油漆芯片 2:當點擊芯片時 A :用邊框突出顯示它已被選中 B:將文本字段/可能是隱藏字段的值更改爲適當的顏色名稱 (因此應該將圖像標記爲靛藍,日光等並相應更新)Javascript/jQuery圖片選取器
我發現了#2這個職位,但無法得到它的工作:jQuery image picker
和這裏的基於上面的鏈接
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<script language="javascript" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
<script type="text/javascript">
$('div#image_container img').click(function(){
// set the img-source as value of image_from_list
$('input#image_from_list').val($(this).attr("src"));
});
</script>
</head>
<body>
<div id="image_container">
<img src="images/vermillion.jpg" />
<img src="images/riverway.jpg" />
<img src="images/solaria.jpg" />
</div>
<form action="" method="get">
<input id="image_from_list" name="image_from_list" type="text" value="" />
</form>
</body>
</html>
任何幫助,將不勝感激在我當前的代碼!!!!
嗯,我結束了其實這裏修復這個問題是我用
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<div id="image_container">
<img src="images/vermillion.jpg" col="red" border="0" />
<img src="images/riverway.jpg" col="blue" border="0" />
<img src="images/solaria.jpg" col="yellow" border="0" />
</div>
<form action="" method="get">
<input id="image_from_list" name="image_from_list" type="text" value="" />
</form>
<script>
$("div#image_container img").click(function() {
$("div#image_container img").attr("border","0");
$(this).attr("border","4");
$("input#image_from_list").val($(this).attr("col"));
});
</script>
</body>
</html>
我不太清楚我得到你的問題是什麼,你能澄清嗎? – Juan
我想顯示3個圖像 - 單擊圖像時,我希望更新表單域的值以反映該點擊。如果可能的話,當前圖像周圍的邊框也會很好。那有意義嗎? – dscl