2016-07-07 83 views
1

我有圖像列表。當選擇圖像時,下一個過程是將特徵添加到同一圖像並對其進行編輯。選擇圖像並知道選擇的圖像

問題是我不知道如何識別選擇哪個特定的圖像。那裏有很多圖像。有沒有像使用js或php或其他方式臨時存儲圖像的方法。

像Java中,如果用戶選擇特定的if語句像

if option==1{ 
    do this..... 
} 

我想類似的東西,讓我知道哪個特定圖像的用戶選擇,您可以設置。我會附上圖片更加重視 image
我想知道如何識別特定圖像中選擇

+0

顯示您的代碼。 – Dave

+1

你沒有真正提供足夠的信息,但它看起來像你可以添加一個類到點擊縮略圖,例如。 '.active',然後在需要時找到該類。或者你可以在它自己的點擊處理程序中使用'this'來引用元素。我們需要看到一些代碼能夠幫助您 –

+0

如果我添加一個活動類到點擊縮略圖,我如何檢索該縮略圖上的特定圖像。你能更加明確嗎 – Seyi

回答

0

從我的理解,這是你所需要的:

$('.image').on('click',function(){ 
    var currentImage=$(this); 
}; 
+0

$(文件)。就緒(函數(){ \t $( '圖像 ')上(' 點擊',函數(){ VAR currentImage = $(本); }; $(」 .side 「)淡出(500).hide(); $(」 SIDE1 「)淡出(500).hide(); \t \t \t \t \t $(」。BOX1" )點擊(函數(){ \t \t \t \t \t \t \t $(」。TAB2" )淡入(500).show(); \t \t \t \t $(「.tab3」)。fadeOut(500).hide(); \t \t \t \t $(「.tab4」)。fadeOut(500).hide(); \t \t \t \t $(「.tab5」)。fadeOut(500).hide(); \t \t \t \t $(「。side1」)。fadeOut(500).hide(); \t \t \t}); – Seyi

0

<!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> 
 
</head> 
 
<script> 
 
\t function chkimage(img) 
 
\t { 
 
\t \t if(img.id=="img1") 
 
\t \t { 
 
\t \t \t img.height = "200"; 
 
\t \t } 
 
\t \t else if(img.id=="img2") 
 
\t \t { 
 
\t \t \t img.width = "200"; 
 
\t \t } 
 
\t } 
 
</script> 
 
<body> 
 
<img id="img1" src="Chrysanthemum.jpg" height="100" width="100" onclick="chkimage(this)"/><br/> 
 
<img id="img2" src="Desert.jpg" height="100" width="100" onclick="chkimage(this)"/><br/> 
 
<img id="img3" src="Hydrangeas.jpg" height="100" width="100" onclick="chkimage(this)"/><br/> 
 

 
</body> 
 
</html>