Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery disable click on other divs once one is selected then make the class clickable again on next set
    primarykey
    data
    text
    <p>This is basically a multiple choice test page. Each div class .choice contains an answer (choice 1-5 etc).</p> <pre><code>$('.choice').click(function () { checkAnswer(this.id, this.title); }); </code></pre> <p>and then the checkAnswer displays a correct or incorrect message and scrolls to the next set of questions. The problem is I want them to only click one choice then when the "next" link appears to have the next set of answer divs to be clickable again.</p> <p>unbind bind on off add/remove class something something Here's the HTML</p> <pre><code> &lt;div class="wrap-choices"&gt; &lt;div id="1a" title="Q1" class="choice"&gt; &lt;p&gt; &lt;span&gt;A. &lt;/span&gt;Car &lt;/p&gt; &lt;/div&gt; &lt;div id="1b" title="Q1" class="choice"&gt; &lt;p&gt; &lt;span&gt;B. &lt;/span&gt;Cat &lt;/p&gt; &lt;/div&gt; &lt;div id="1c" title="Q1" class="choice"&gt; &lt;p&gt; &lt;span&gt;C. &lt;/span&gt;Cow &lt;/p&gt; &lt;/div&gt; &lt;div id="1d" title="Q1" class="choice"&gt; &lt;p&gt; &lt;span&gt;D. &lt;/span&gt;All of the above &lt;/p&gt; &lt;/div&gt; </code></pre> <p>here's the portion for checking the answer in array</p> <pre><code>function checkAnswer(answerID,qNumber) { var arr = ['1d', '2c', '3d', '4b']; var correct = $.inArray(answerID, arr); //display an incorrect or correct popup if (correct &gt; -1) { $('.' + qNumber + ' .correct').show(); } else { $('.' + qNumber + ' .incorrect').show(); } //add code to disable clicking any other div here $('.next').show(); //and then when clicking on that next image, the click is enabled again for those divs }; </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.
 

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