Skip to content Skip to sidebar Skip to footer

Stop The Jquery Function After One Execution

I have the function Nextthing that hides first iframe and shows the next one, but as you will see in the code of the function I did just for only one next iframe, so if he makes th

Solution 1:

you can use

.one() handler.. It will run the code once and stop the execution.

$('input[type=submit]').one('click', function() {
  $("#i").hide();
   $('.table').eq(1).find('tbody tr').eq(2).after('<tr><td colspan=10><iframe class="iframe"     
    src="/msg.html?msgId='+$('.table').eq(1).find('tbody tr').eq(2).find('td 
    a').eq(0).text()+'&constant=1"></iframe></td></tr>);

});

Solution 2:

For this I usually just have a global variable such as elTriggers = false and check for that and make it true when it is triggered. You could also check out jquery's one function.

Post a Comment for "Stop The Jquery Function After One Execution"