Note that there are some explanatory texts on larger screens.

plurals
  1. POLegacy IE hack: label not focusing input
    primarykey
    data
    text
    <p>I am working with legacy code and I've stumbled across this piece of art:</p> <pre><code>//IE Hacks if (navigator.appName == 'Microsoft Internet Explorer') { $("label").live('click', function() { $('#'+$(this).attr('for')).click().click().click(); }); } // End IE Hacks </code></pre> <p>I was told this was written, because labels were not always working in IE and this trick fixed it. Also it didn't work with two <code>.click()</code> calls, but the all three were needed.</p> <p>The jQuery version used is <code>1.4.2</code>.</p> <p>I want to refactor this to use feature detection and a more elegant solution.</p> <p>I looked on Google for label problems in IE and stumbled only on problems with hidden inputs.</p> <p>Does anyone know what could be the problem which this code solves?</p> <p>Is there a more elegant solution?</p> <p><strong>UPDATE</strong>:</p> <p>Do you think there is not a problem which this code could have possibly solved and I should just remove it?</p> <p><strong>UPDATE 2</strong>:</p> <p>I have found a problem with labels on the site. Here is a piece of HTML:</p> <pre><code>&lt;div class="remember-me"&gt; &lt;input type="hidden" name="remember" value="0"&gt; &lt;input type="checkbox" id="remember" name="remember" value="1" class="checkbox-input" rel="remember"&gt; &lt;label class="label-remember" for="remember"&gt;Keep me logged in&lt;/label&gt; &lt;/div&gt; </code></pre> <p>This HTML code is inserted into the page with Ajax so it might be related to the problem described from kevmc.</p> <p>In Internet Explorer 7 clicking the label does not check the checkbox. Instead it focuses the label (with a thin dotted border).</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.
    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