Javascript 用图像替换文本
当用户填写表单并按“提交”时,在提交信息时,表单将被禁用。我使用以下代码禁用表单:Javascript 用图像替换文本,javascript,jquery,html,Javascript,Jquery,Html,当用户填写表单并按“提交”时,在提交信息时,表单将被禁用。我使用以下代码禁用表单: $form.find('button').prop('disabled', true); 如何用加载图像替换按钮的文本?就这样做吧 $form.find('button').prop('disabled', true).html('<img src="yourimagesoruce">'); $form.find('button').prop('disabled',true.html(''); 如
$form.find('button').prop('disabled', true);
如何用加载图像替换按钮的文本?就这样做吧
$form.find('button').prop('disabled', true).html('<img src="yourimagesoruce">');
$form.find('button').prop('disabled',true.html('');
如果要将“加载图像”放置到按钮中,则作为一种解决方案,您可以将“背景图像”属性设置为带有“加载图像”url的按钮。您还可以设置其他属性来定义图像的外观
例如:
$form.find('button').prop('background-image', 'url("img/loading.gif")');
只需点击按钮并添加背景
$('input[type=submit]').css('background', "url('please_wait2.png') no-repeat top left");
并禁用它
$('input[type=submit]').prop("disabled",true)
您可以使用替换按钮
$(":submit").on("click", function (e) {
$("form").prop("disabled", true);
$(this).replaceWith("<img id='loadingImg' src='http://www.loadinfo.net/images/preview/11_cyrcle_one_24.gif?1384388177' />");
});
$(“:提交”)。在(“单击”)上,函数(e){
$(“表格”).prop(“禁用”,真);
$(此)。替换为(“”);
});
请发布您的HTML代码并检查链接这不是该问题的重复,该问题涉及mootools,但该问题涉及JQuery。当按钮stat启用或禁用时,此css样式将显示等待图像,我写了还是错了?提交表单时,它将加载图像作为按钮的背景图像,然后将其禁用。