Note that there are some explanatory texts on larger screens.

plurals
  1. PO$(":focus") returns no element for <input type="file" /> in Firefox
    primarykey
    data
    text
    <p>I can't seem to get the currently focused/active element as a jQuery object <em>in Firefox</em>, if it is an <code>&lt;input type="file" /&gt;</code>. It works on other input types (text, password, submit, others) and on other element types (<code>&lt;select&gt;</code>, <code>&lt;textarea&gt;</code>, others).</p> <h2>HTML</h2> <pre class="lang-html prettyprint-override"><code>&lt;input type="file" /&gt; </code></pre> <h2>Javascript</h2> <pre class="lang-js prettyprint-override"><code>// Cannot find input type file elements with :focus, // $focused.length is always 0 in Firefox (tested using FF 10.0.1) var $focusedTest1 = $(':focus'); // This line throws for Firefox (tested using FF 10.0.1) // Permission denied to access property 'nodeType' // @ http://code.jquery.com/jquery-1.7.1.js:108 // in jQuery.fn.init, below "Handle $(DOMElement)" var $focusedTest2 = $(document.activeElement); </code></pre> <h2>Steps to reproduce</h2> <ol> <li>Use Firefox.</li> <li>Focus the file box: <ul> <li>press tab until you reach it</li> <li>or click in it.</li> </ul></li> <li>While focusing the file box, try to get a result from <code>$(':focus')</code>.</li> </ol> <p>See <a href="http://jsfiddle.net/joelpurra/bzsv7/" rel="nofollow">jsFiddle demonstration of getting the id of the focused element</a> - test it with Firefox.</p> <p><strong>Does anyone have a solution for getting the focused/active element as a jQuery object that works for <code>&lt;input type="file" /&gt;</code>?</strong></p> <p>The solution needs to be fully generic as the functionality is part of a plugin. I will not have control over the page the script will run on.</p>
    singulars
    1. This table or related slice is empty.
    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