2013-08-24 62 views
-1
IMG路徑
  <div class="em-main" style="text-align: center"> 
     <div class="em-div-head" align="center"> E-Shop Jewellery </div> 
      <div class="em-textbox" style="border:hidden"> 
       <input type="text" value="To:" name="recipient" style="width:97%"> 
      </div> 
     <div id="em"> 
      <div class="em-middle"> 
       <div style="border-bottom:solid 1px #CCCCCC"> 
       <textarea class="em-textarea" onblur="if (this.value == '') { this.value='Write a 
       message..'; }" onfocus="if(this.value == 'Write a message..') { this.value = 
        ''; }" value="Write a message.." name="message">Write a message..</textarea> 
      </div> 
      <div id="em_rt_tp_scroller" class="em_rt_tp_scroller"> 
      <div id="em-rightscrollerimage" style="border:none"> 
    <div class="em-mdimage"><img class="mail" src=" http://localhost:8080/weather 
     /servlets.ImgDisplayServlet?id=D:\EML\workspace\assets\tried- 
     imgs\18__1882_IMG_5731_203_173.png " alt="imagecontainer image" style="max- 
      height:100%; max-width:100%;"> 
     <ul> 
     <img id="em-delete" class="removeicon" width="7" height="7" title="Remove" bottom="10%" 
      src="jqe13/image/delete_s.PNG"> 
      </ul> 
     </div> 
     <div class="em-mdimage"> 
      <img class="mail" src=" http://localhost:8080/weather 
       /servlets.ImgDisplayServlet?id=D:\EML\workspace\assets\tried- 
       imgs\13__1882_IMG_5731_120_124.png " alt="imagecontainer image" style="max- 
       height:100%; max-width:100%;"> 
      <ul> 
      <img id="em-delete" class="removeicon" width="7" height="7" title="Remove"   
        bottom="10%" src="jqe13/image/delete_s.PNG"> 
      </ul> 
     </div> 
     <div class="em-mdimage"> 
      <img class="mail" src=" http://localhost:8080/weather 
      /servlets.ImgDisplayServlet?id=D:\EML\workspace\assets\tried- 
       imgs\15__1882_IMG_5731_341_137.png " alt="imagecontainer image" style="max- 
       height:100%; max-width:100%;"> 
      <ul> 
       <img id="em-delete" class="removeicon" width="7" height="7" title="Remove"  
       bottom="10%" src="jqe13/image/delete_s.PNG"> 
      </ul> 
      </div> 
      </div> 
     </div> 
     </div> 
     <div class="em-bottom" align="center"> 
      <input id="SEND" type="button" value="send" name=""> 
       <input id="CANCEL" type="button" value="cancel" name=""> 
     </div> 
     </div> 
     </div> 

上面的代碼運行HTML代碼的郵件,包括圖像sources.i附上3個圖像 到類=「EM-mdimage」。可任何一個可以幫助我得到所有3個圖像路徑(如D:\ EML \ workspace \ assets \ tried-imgs \ 18__1882_IMG_5731_203_173.png)使用jquery。然後我將發送 這3條路徑到我的servlet點擊「發送」按鈕。 我是新來jquery.I嘗試了一些選擇器,但我沒有得到這些路徑。 在此先感謝。我怎樣才能使用jQuery

+0

jQuery的.attr('src')應該可以幫到你。你可能需要將它彈出一個數組,但是這會得到你所需要的信息 –

+0

對不起,如果我誤解了這個問題,我正在打電話,但函數.attr('src')有幫助嗎? –

回答

1

不能獲得系統文件路徑(例如,D:\EML\workspace\assets\tried-imgs\18__1882_IMG_5731_203_173.png

的瀏覽器不能夠訪問你的本地文件系統,它不用說,JavaScript沒有訪問遠程文件系統也是如此。

你可以得到src屬性

$("img").each(function(){ 
    console.log($(this).attr("src")); 
}); 
+0

嗨,謝謝你,使用這段代碼我得到路徑。 – honey

+0

$( '#SEND')生活( '點擊',函數(事件){ \t變種S;。 VAR IMGS = 「」; $( 「郵件」),每個(函數(){ \t變種(i); \t imgs = imgs + path [1] +'〜(this) '; \t console.log(imgs); \t}); s = imgs; console.log(s);}); – honey

+0

根據我的要求,我將ur代碼更改爲上面的行,然後我得到這樣的輸出........ undefined〜D:\ EML \ workspace \ assets \ tried-imgs \ 18__1688_IMG_5749_140_10 1.png〜D:\ EML \ workspace \ assets \ tried-imgs \ 1__1688_IMG_5749_134_117.png〜D:\ EML \ workspace \ assets \ tried-imgs \ 15__1688_IMG_5749_144_123.png〜但我在路徑前得到了「undefined」,因爲這一行「\t imgs = imgs + path [1] +'〜';「 .....如果它沒有得到我會發送完美的路徑到我的servlet ...請給我任何建議...提前謝謝... :) – honey

-1

此圖像會爲你工作, 警報($( 'IMG')[0]的.src);