按钮上的数据加载文本 [英] Data loading text on button
本文介绍了按钮上的数据加载文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在这里检查了类似的问题,但是似乎没有一个问题可以解决我的问题.
I've checked similar questions here, but none of them seemed to solve my problem.
我正在尝试将数据加载文本添加到我的提交"按钮中,但到目前为止还没有运气.
I'm trying to add data-loading-text to my submit button, but with no luck so far.
我正在使用Bootstrap 4!
I'm using Bootstrap 4!
这是我的HTML:
<button type="submit" id="submit" class="btn btn-primary btn-lg mt-2" data-loading-text="Sending...">Submit message!</button>
这是我尝试过的最后一个jquery代码:
This was the last jquery code I tried:
$(function() {
$(".btn").click(function(){
$(this).submit('loading').delay(1000).queue(function() {
// $(this).button('reset');
});
});
});
谢谢
推荐答案
尝试一下.
<!DOCTYPE html>
<html>
<head>
<style></style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script>
function MyCustomFunction(){
$("#submit").text("Loading...");
$(this).submit('loading').delay(1000).queue(function () {
// $(this).button('reset');
});
}
</script>
</head>
<body>
<button type="submit" onclick="MyCustomFunction()" id="submit" class="btn btn-primary btn-lg mt-2" data-loading-text="Sending...">Submit message!</button>
</body>
</html>
对于提交"按钮,唯一可能的方法是在单击时绑定自定义函数,并将action属性更改为事件处理程序.
In case of Submit button the only possible way is to bind a custom function on click and change the action attribute to event handler.
这篇关于按钮上的数据加载文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文