2013-04-08 152 views
0

嗨我試圖改變超鏈接的圖像點擊如下。但是選擇按鈕的圖像不會更改爲loading.gif。我究竟做錯了什麼?我是jquery的新手。預計感謝點擊更改超鏈接圖像

<HTML><HEAD> 
    <SCRIPT type=text/javascript src="jquery.js"></SCRIPT> 
    </HEAD> 
    <BODY> 
    <TABLE> 
    <TBODY> 
    <TR> 
    <TD><A id=webservice_submit href="javascript:document.frm_correction.submit()" jQuery1365443220846="2"> 
     <IMG onmouseover="MM_swapImage('Correction subj','','http://localhost:6868/corrmgr/img/select_up.gif',0)" onmouseout=MM_swapImgRestore() name="Correction Subj" alt="Correction Subj" src="http://localhost:6868/corrmgr/img/select.gif" oSrc="http://localhost:6868/corrmgr/img/select.gif"> 
     </A></TD></TD></TR></TBODY></TABLE> 
    <DIV style="DISPLAY: none" id=loading jQuery1365443220846="3"><IMG name="Please wait..." alt="Please wait while the request is being processed..." src="http://localhost:6868/corrmgr/img/bert2.gif"> </DIV> 
    <SCRIPT language=javascript> 
     var $loading = $('#loading'); 

     $('#webservice_submit').click(function(){  
      $loading.toggle();  
      if($loading.is(':visible')){ 
       alert("invoking web services"); 
       $('#image img').attr('src', 'http://localhost:63531/corrmgr/img/loading.gif'); 
       return ($(this).attr('disabled')) ? false : true;   
      } 
     }); 

     $('#loading').hide(); 
    </SCRIPT> 
    </BODY></HTML> 

回答

0

我想你想指定加載程序映像到下面的圖片標籤

<IMG name="Please wait..." alt="Please wait while the request is being processed..." 
src="http://localhost:6868/corrmgr/img/bert2.gif"> 

如果我理解你...你改變你的代碼像下面...

FROM:

$('#image img').attr('src', 'http://localhost:63531/corrmgr/img/loading.gif'); 

TO:

$("img[name='Please wait...']").attr('src', 'http://localhost:63531/corrmgr/img/loading.gif'); 
+0

感謝Pandian。加載程序是我嘗試的一種方式,我也嘗試過,但仍然無法運行,下面是修改後的代碼:$('#webservice_submit ')。點擊(函數(){ \t $ loading.toggle(); \t如果($ loading.is(':可見「)){ \t \t警報( 」調用Web服務「); \t \t $ ('img [name ='Please wait ...')。attr('src','http:// localhost:63531/corrmgr/img/loading.gif'); \t} \t}); – spayasam 2013-04-08 19:35:12

3

你的選擇是不對的。更改此:

$('#image img') 

這樣:

$('#image') 

並給予<img>相應id

<IMG id="image" ...> 
+0

嗨阿德里安,爲感謝回覆。我現在改變了代碼如下,但無濟於事。 – spayasam 2013-04-08 19:22:47

+0

對不起,我無法提供修改後的代碼(大小限制)。這是我改變的塊。 spayasam 2013-04-08 19:25:22