单击后如何禁用html按钮而不是提交按钮 [英] how to disable a html button after it has been clicked not a submit button

查看:97
本文介绍了单击后如何禁用html按钮而不是提交按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个html按钮,当您按它时,它应该为您提供距离您所在的商店的距离,因此,当您按它时,它们现在出现了问题,因为这是在早期阶段,每次打印该信息时按下按钮时,我现在想如何在按下一次按钮时将其禁用,然后在按下另一个按钮时将其重新激活,这不是提交按钮,所以我对该按钮的代码是:

hi i have a html button and when you press it, it should give you the distances of shops from where you are so when you press it they appear now the problem is because it is in early stages the information is printed everytime the button is pressed i would just like to now how to disable it when it has been pressed once and then reactivate it when another button has been pressed this is not a submit button my code for the button is :

   <button onclick="getLocation()">Search</button>

任何帮助将不胜感激

推荐答案

我认为这对您来说很清楚.

I think its very clear for you..

在click事件中调用getlocation()方法.

Call your getlocation() method inside the click event..

工作中的小提琴

代码

$( "#bind" ).click(function() {
   $(this).attr("disabled", "disabled");
   $("#unbind").removeAttr("disabled");
});
$( "#unbind" ).click(function() {
     $(this).attr("disabled", "disabled");
     $("#bind").removeAttr("disabled");
});

输出

这篇关于单击后如何禁用html按钮而不是提交按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆