Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用JQuery在单击一次后禁用href_Jquery_Laravel - Fatal编程技术网

如何使用JQuery在单击一次后禁用href

如何使用JQuery在单击一次后禁用href,jquery,laravel,Jquery,Laravel,我在Laravel-5.8的一个项目上工作 当用户单击href时,它会发布所有受访者: 控制器: public function submit_all_respondents(){ ... Notification::route('mail', $details['employee_respondent_email']) ->notify(new \App\Notifications\RespondentSubm

我在Laravel-5.8的一个项目上工作

当用户单击href时,它会发布所有受访者:

控制器:

public function submit_all_respondents(){
     ...
  Notification::route('mail', $details['employee_respondent_email'])
                                ->notify(new \App\Notifications\RespondentSubmit($details));
  Session::flash('success', 'Email sent to respondents successfully');
  return redirect()->back();
}  
看法


只需单击一次,我希望href被禁用并变为“Processing…”,直到完成为止

如何实现这一简单的解决方案:

$(...).click(function(e) {
    if ($(this).is(':disabled')) {
        e.preventDefault();
    }

    $(this).prop('disabled', true)
        .html('<i class="fas fa-arrow-right"></i> Processng ...');
});
$(…)。单击(函数(e){
如果($(this).is(':disabled')){
e、 预防默认值();
}
$(this.prop('disabled',true)
.html('Processng…');
});

您可以使用CSS禁用
href
。 如果添加CSS样式
指针事件:无,该选择器将不接受任何指针事件。(与禁用的
相同

因此,最好创建一个名为
.processing
的新类,并在用户单击它时将其添加到选择器中

函数处理(事件){
event.target.className+=“正在处理”;
}
处理{
指针事件:无;
不透明度:0.5;
}

单击锚定标记链接时,您将进入一个新页面。直到完成什么操作?在显示的内容中,当单击
@charlietfi-我添加了控制器我使用了:$(#review_comment_btn-submit)。单击(function(){$(this.prop('disabled',true.))。html('Processng…'););但不起作用id=review\u comment\u btn-submit您在示例中的
周围缺少引号。\review\u comment\u btn-submit
。它将更改为处理。。。但没有禁用href。它仍然允许用户点击它来改变处理。。。但没有禁用href。它仍然允许用户能够单击HREF,直到未禁用为止
$(...).click(function(e) {
    if ($(this).is(':disabled')) {
        e.preventDefault();
    }

    $(this).prop('disabled', true)
        .html('<i class="fas fa-arrow-right"></i> Processng ...');
});