Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery .focus() and .blur() not working in Chrome or Safari
    primarykey
    data
    text
    <p>I am creating a survey form that needs to have each question and set of answers highlighted (by changing the background color) when the user focuses on them. .focus() and .blur() both work in Firefox and IE, but <strong>not entirely</strong> in Safari and Chrome. I also tried .focusin() and .focusout() with the same results. <em>EDIT: Clicking does not fire the focus event, but tabbing through the input fields does.</em> I say <strong>not entirely</strong> because it works for text inputs, select inputs and textarea inputs; but not radio and checkbox inputs.</p> <pre><code>$(document).ready(function() { $("form li").focusin(function() { $(this).addClass("over"); }).focusout(function() { $(this).removeClass("over"); }); }); </code></pre> <p>This is being applied to blocks of html similar to this:</p> <pre><code>&lt;li&gt; &lt;label for="webmail" class="desc"&gt;Email&lt;/label&gt; &lt;input type="text" name="webmail" id="webmail" /&gt; &lt;/li&gt; &lt;li&gt; &lt;label for="business" class="desc"&gt;Purpose of your Charter Flight:&lt;/label&gt; &lt;div&gt; &lt;span&gt; &lt;input type="radio" name="purpose" id="business" class="radio" /&gt; &lt;label class="choice" for="business"&gt;Business&lt;/label&gt; &lt;/span&gt; &lt;span&gt; &lt;input type="radio" name="purpose" id="pleasure" class="radio" /&gt; &lt;label class="choice" for="pleasure"&gt;Pleasure&lt;/label&gt; &lt;/span&gt; &lt;/div&gt; &lt;/li&gt; </code></pre> <p>I tried messing around with toggles, but I am looking for a more elegant solution that doesn't involve using convoluted logic to make it work. Any ideas?</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