简体   繁体   English

单击时带有图像和加载元素ID的按钮

[英]Button with image and loading element id when clicked

I've made an application that makes full use of ajax, and what I need to do is: I want a button with a description + image that when clicked is disabled and instead of the original image in the button, appears the ajax loading element id inside the button. 我已经制作了一个可以充分利用ajax的应用程序,我需要做的是:我想要一个带有说明+图片的按钮,当单击该按钮时,该按钮被禁用,而不是按钮中的原始图像,而是显示ajax加载元素按钮内的ID。 And when the ajax loading is complete, the original image of the button returns to the normal. 当ajax加载完成时,按钮的原始图像将恢复正常。

Is there any good source on how to do something like this? 有什么好的方法可以做这样的事情吗? What do you guys suggest? 你们有什么建议?

if your button is image you can just change it's source like this 如果您的按钮是图像,您可以像这样更改其来源

 
function call_my_method(el)
{
  //ajax call and stuff
 el.setAttribute('src', 'loading.gif');
}

and all you have to do is return old image once you get response from server, same way as you put the loading.gif 从服务器获得响应后,您要做的就是返回旧图像,就像放置loading.gif一样

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM