Note that there are some explanatory texts on larger screens.

plurals
  1. POCSS hover effect on ajax content and mobile devices
    primarykey
    data
    text
    <p>I've build a quiz. Each question has 2 answers. When the visitor answers a question, the next one is loaded using Ajax. Before the questions are loaded the visitor has to click a start button first, so the HTML for the questions isn't included in the initial page load.</p> <p>The problem is when a question is anwsered, the hover effect from the previous question is still active when the next one is loaded.</p> <p><strong>For example:</strong> I anwser question 1 with "B" > question 2 is loaded > the hover effect is active on button B for question 2</p> <p>I've included an image to make this more clear. </p> <p><img src="https://i.stack.imgur.com/b8yub.png" alt="enter image description here"></p> <p>I only have this on mobile devices (iPhone, iPad,...) but not on my laptop.</p> <p>I've done some research if I can alter the hover pseudo class, but apparently this isn't possible using javascript.</p> <p>I think the problem is that the HTML is the same for each question, so the hover state stays active for the css class when the first question is answsered.</p> <p>I can't supply a jsfiddle because the questions are entered as a content type in Drupal, and I can't include the entire Drupal in a fiddle. But here is the HTML and CSS.</p> <pre><code>&lt;div class="quiz_st_content form-wrapper" id="ajax_form_multistep_form_content"&gt; &lt;div class="quiz_st_content_answer form-wrapper" id="edit-a--2"&gt; &lt;div class="quiz_st_content_answer_info_wrapper"&gt;Option A&lt;/div&gt; &lt;div class="quiz_st_content_answer_button_wrapper"&gt; &lt;input class="quiz_st_content_answer_button form-submit ajax-processed" type="image" id="edit-answer-a-2" name="answer_a_2"&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="quiz_st_content_answer form-wrapper" id="edit-b--2"&gt; &lt;div class="quiz_st_content_answer_info_wrapper"&gt;Option B&lt;/div&gt; &lt;div class="quiz_st_content_answer_button_wrapper"&gt; &lt;input class="quiz_st_content_answer_button form-submit ajax-processed" type="image" id="edit-answer-b-2" name="answer_b_2"&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>CSS</p> <pre><code>input.form-submit.quiz_st_content_answer_button { margin: 0; border-radius: 50px; -moz-border-radius: 50px; -webkit-border-radius: 50px; height: 30px; width: 30px; padding: 20px; background: #ccc; } </code></pre> <p>Hover</p> <pre><code>input.form-submit.quiz_st_content_answer_button:hover { background: #ba043f; } </code></pre> <p>As mentioned above, this only happens on mobile devices. I've been bashing my head at this for hours now and I'm clueless on how to resolve this.</p> <p>If anyone could help me, or point me in the right direction it would be greatly appreciated.</p>
    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.
 

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