Note that there are some explanatory texts on larger screens.

plurals
  1. POOne div button, firing multiple functions, after each other per new click
    primarykey
    data
    text
    <p>I am trying to have one div box act as a main button for multiple functions; and these functions would fire consecutively after each other; but per new CLICK. <em>Eg,</em> Click = Function fires. Click = next function in line fires, and so forth. Currently I have the below; which is fine, but it is not firing the functions consecutively as they are coded, per click as needed; one after another. Live demo of my dilemma at '<a href="http://bit.ly/10BW89N" rel="nofollow">http://bit.ly/10BW89N</a>'</p> <p><em><strong>So how to create one button and 30 functions that will be called on each click. If function is defined it will call the function otherwise it will alert the click number?</em></strong></p> <pre><code>$(document).ready(function () { var a1_Events = [function1, function2, function3, function4, function5, function6, function7, function8], a1_c = 0; function function1() { alert('Click 1!'); } function function2() { alert('Click 2!'); } function function3() { $("#area1").hide(); $("#area2").show(); alert('Click 3!'); } function function4() { alert('Click 4!'); } function function5() { alert('Click 5!'); } function function6() { $("#bg_div").hide(0).delay(1500).show(0); $("#bg_skew").show(0).delay(1500).hide(0); alert('Click 6!'); } function function7() { alert('Click 7!'); } function function8() { $("#area1").hide(0).delay(1500).show(0); $("#area2").hide(0).delay(1500).show(0); $("#sound1").show(0).delay(4500).hide(0); document.getElementById("id1").play(); $("#hammer").show(0).delay(1500).hide(0); $("#youwin").show(0).delay(3500).hide(0); alert('Click 8!'); } $('#area1').click(function () { a1_Events[a1_c++ % a1_Events.length](); }); $("#area2").click(function () { $("#area1").show(); $("#area2").hide(); alert('Click 9!'); }); }); function alert(msg) { $("#alert").text(msg).show(0).delay(1500).hide(0); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload