javascript - Temporarily Disable a DIV while setInterval is running -


I want to disable some part of my HTML while IM setInterval is running SetInterval complete It is done.

  & lt; Div id = "on" & gt; Click on this: & lt; Span id = "status" & gt; Enabled & lt; / Span & gt; & Lt; / Div & gt; & Lt; Button ID = "Run" & gt; Load & lt; / Button $ ('# run'). On ('click', function) {var i = 0; Var go = setInterval (function () {i ++; $ ('#run') .html ('Loading + I +' or 10 ... '); $ (' # status'). Html ( $ '(' # '); $ (' # '); $ (' # Run ' === 10) {clear interval (go);}}, 1000);}); $ ('At #'). ('Click', function () {$ ('# condition'). Html ('clicking');});   

Here, what I want to achieve, when I click on the loading button click on it until the event Do not accept unless clicked is loading but the click is still triggered. Is there any other way to do this?

[and I want to use disabled = "disabled"]

If you do not want to have a click event to trigger the callback, then undo the event or set the flag checked in the callback. Apart from this, you are unbinding within the callback, such an event will not be unbound until it is called for the first time

  $ ('# run'). On ('click', function () (var ==; $ ('# status') .html ('disabled'); $ ("at #"). Unbind ('click keyup keypress keydown') go to var go = SetInterval (function () {i ++; $ ('# Run'). Html ('Loading + I +' or 10 ... '); if (i === 10) {Clear Interval ( $ ('# Condition'). $ '' Enabled '); $ (' # run ') .html (' full '); $ ("at #"). ("Click", onDivClicked) ;}}, 1000);}); $ ('At #'). ('Click', on-devlated); Function ON Dualed () {$ ('# status'). Html ('clicking'); }   

or set a flag

  $ ('#in'). Data ("active", is true); $ ('# Run'). ('Click', function () {var i = 0; $ ('# status'). Html (' disabled '); $ ("# on"). Data ("active" (' Loading + Eye + 'Or 10 ...'); if (i === 10) {i ===} {i <+++; $ ('# run'). Html $ ('# condition'). Html 'Enabled'); $ ('# run') .html ('full'); $ ("at #"). Data ("active", true);}}, 1000);}); $ ('At #'). Return ('$'); ('$'); ('' click '', function () (if;! $ (This) .data ("active")); $ ('# condition'). Html ('clicking');});  < / Pre>  

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -