How about js or jqury? after the first button is clicked, wait 10 seconds for another button to operate? I made a web print control, because I had to wait for the order to be loaded before printing. if it could not be loaded, he would only print the order he loaded. So I want to make a button query, wait 10 seconds, another... js or jqury how to click the first button and wait 10 seconds for another button to operate?
I made a web print control, because I had to wait for the order to be loaded before printing. if it could not be loaded, he would only print the order he loaded. So I want to make a button query, wait 10 seconds, another printed button can be clicked to print.
Reply content:
How about js or jqury? after the first button is clicked, wait 10 seconds for another button to operate?
I made a web print control, because I had to wait for the order to be loaded before printing. if it could not be loaded, he would only print the order he loaded. So I want to make a button query, wait 10 seconds, another printed button can be clicked to print.
1. you can use disabled to control the second print button;
The default disabled value of button1 is false, which can be operated;
The default disabled value of button2 is true and cannot be operated.
$ ('# Button1 '). click (function () {// logic ........ setDisable () ;}); function setDisable () {setTimeout (function () {// remove the disabled attribute of the second button after 10 seconds $ ('# button2 '). removeAttr ("disabled") ;}, 10000 );}
2. you can also hide the second print button.
$ ('# Button1 '). click (function () {// logic ........ setDisable () ;}); function setDisable () {setTimeout (function () {// The second button is displayed after 10 seconds ('symbol button2'symbol .css ("display", "block ");}, (10000 );}
SetTimeout
After you click the first button, give the other button a disabled = "disabled" and give it a timer. the timer ends and disabled = false. you can give it a try.
After clicking it, give it a timer setTimeout, and then execute another button.
I don't like what others say. it's too simple to understand. what I want is definitely not a short answer.
The principle is: After you click the first button, add a click event to the second button in 10 seconds.
$ (# Btn-1 '). click (function () {// here write # The Code setTimeout (function () {$ ('# btn-1') to be executed when the btn-2 is clicked '). click (function () {// here write # code to be executed when the btn-1 is clicked}) ;}, 10000 );});
Assume that the buttons are A and B respectively.
Var $ btnA = $ ('# btn-A'); var $ btnB = $ (' # btn-B '); $ btnB. prop ('disabled ', true); $ btnA. on ('click', function () {setTimeout (function () {$ btnB. prop ('disabled ', false) ;}, 10000) ;}); $ btnB. on ('click', function () {// Print });
The key is
$btnB.prop('disabled',false);
If your button A contains asynchronous code, you need to wait for the back-end to return and then enable button B. put the above code in the callback function for execution.