2013-11-15 27 views
1

有誰知道添加一些JQuery的方式,將允許用戶懸停在Razor的foreach循環中動態創建的UNKNOWN ID?當圖像被隱藏或懸停並執行.show()時,我需要獲取id;爲那個形象。我在其他頁面上使用一個圖像工作,但無法弄清楚對於許多未知ID的圖像要做什麼。MVC 4剃刀圖像鼠標放大顯示

這裏是圖像的div有兩個圖像。完整的圖像顯示在較小的圖像上,並且在鼠標移出或沒有懸停時消失。

<div class="listEntriesPhoto" style="display:inline-block; vertical-align:top;"> 
      <img id="[email protected]" src='~/documents/@item.ImageName' alt="repeating default photo of woman" /> 

      <!--This is for image hover for larger picture--> 
      <div id="[email protected]" style="display:none;" > 
       <img id="[email protected]" src='~/documents/@item.ImageName' alt="Submitted image"/> 
      </div> 
     </div> 

任何幫助將是偉大的,並提前感謝!

+0

是類 「listEntriesPhoto」 根div元素? – Jared

回答

2

這應該爲你做它:

var photoList = $(".listEntryPhoto").find("img"); 
    .each(photoList, function(){ 
      var image = $(this); 
      // Whatever code you used for one image goes here 
      // using the image variable 
    }; 
+0

嗨Jared!我終於有時間迴應了,因爲我原本是在緊急的最後期限之後才忘記的。無論如何,我給了你答案的功勞,因爲我最終拼湊了你發佈的內容和我已經擁有的內容,並且它的工作非常好!這裏是代碼: – brharrison

+0

這裏是代碼:$(「。DiagramLeft」)。mouseenter(function(){ $(this).next(「。FullDiagramLeft」)。show('normal'); }); ('。FullDiagramLeft')。mouseleave(function(){ $(this).hide('normal'); }); – brharrison