Note that there are some explanatory texts on larger screens.

plurals
  1. POJQuery works in Firefox, but not in IE
    primarykey
    data
    text
    <p>Anyone know why the following JQuery expression works in Firefox but not in IE or Chrome?</p> <pre><code>$('form :hidden:last').attr('name') </code></pre> <p>An alert statement reveals that in IE the expression is undefined.</p> <p>UPDATE: Here is some HTML that fails.</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; &lt;html&gt; &lt;head&gt; &lt;script type="text/javascript" src="/js/jquery-1.3.2.min.js"&gt; &lt;/script&gt; &lt;script type="text/javascript"&gt; function addItem() { var v = $('form :hidden:last').attr('name'); var n = /(.*)input/.exec(v); var newPrefix; if ( n[1].length == 0 ) { newPrefix = '1'; } else { newPrefix = parseInt(n[1])+1; } var lastExercise = $('form tr:last select:first').attr('value'); var oldElem = $('form tr:last'); var newElem = oldElem.clone(true); var lastHidden = $('form :hidden:last'); lastHidden.val(newPrefix); var pat = '=\"'+n[1]+'input'; newElem.html(newElem.html().replace(new RegExp(pat, 'g'), '=\"'+newPrefix+'input')); newElem.appendTo('table'); $('form tr:last select:first').attr('value', lastExercise); $('form :hidden:last').val(''); } function removeItem() { var rows = $('form tr'); if ( rows.length &gt; 2 ) { rows.filter(":last").remove(); $('form :hidden:last').val(''); } else { alert('Cannot remove any more rows'); } } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form autocomplete="off" method="post" action=""&gt; &lt;div&gt; &lt;input type="button" onclick="addItem(); return false;" value="Add Item" /&gt; &lt;input type="button" onclick="removeItem(); return false;" value="Remove Last Item" /&gt; &lt;/div&gt; &lt;table&gt; &lt;tr&gt; &lt;th&gt;Name&lt;/th&gt; &lt;th&gt;Weight&lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;input type="text" name="input1" id="input1" value="" /&gt; &lt;/td&gt; &lt;td&gt; &lt;input type="text" name="input2" id="input2" value="" /&gt; &lt;select name="input3" class="unitsInput"&gt; &lt;option value="0"&gt; Pounds &lt;/option&gt; &lt;option value="1"&gt; Kilograms &lt;/option&gt; &lt;/select&gt; &lt;/td&gt; &lt;td&gt; &lt;input type="hidden" name="input4" id="input4" value="" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;div&gt; &lt;select name="input8"&gt; &lt;option value="0"&gt;0&lt;/option&gt; &lt;option value="1"&gt;1&lt;/option&gt; &lt;option value="2"&gt;2&lt;/option&gt; &lt;/select&gt; &lt;/div&gt; &lt;div&gt; &lt;input type="submit" name="submit" id="submit" value="Submit" /&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    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