2013-04-08 155 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