Note that there are some explanatory texts on larger screens.

plurals
  1. PONot able to get .focus to work on dynamically created input elements
    primarykey
    data
    text
    <p>I am having an issue that once my page is rendered, the focus is not being set on the first input element of a dynamically created table/input.</p> <p>In the .jsp I have the following:</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function(){ if(_page != "one") { buildTable(shipQty); $('#shipItems[0].barCode').focus(); } &lt;/script&gt; </code></pre> <p>There is an included .js which contains the buildTable function</p> <pre><code>function buildTable(shipQty) { var _tbl = $('&lt;table&gt;').attr({ id : 'barCodeTable', border : '1' }); _tbl.append($('&lt;tr&gt;').append($('&lt;td&gt;').text('Box BarCode'),$('&lt;td&gt;').text('INBOUND Tracking Number'))); for ( var _index = 0; _index &lt; shipQty; _index++) { var _inputBarCode = $('&lt;input&gt;').attr({ class : 'form-med', type : 'text', name : 'shipItems[' + _index + '].barCode', id : 'shipItems[' + _index + '].barCode', maxlength: '8' }).change(_barCodeChange); var _shippingTrackingCode = $('&lt;input&gt;').attr({ class : 'form-med', type : 'text', name : 'shipItems[' + _index + '].shipCompanyBarCode', id : 'shipItems[' + _index + '].shipCompanyBarCode' }).change(_trackingNumberChange); _tbl.append($('&lt;tr&gt;').append($('&lt;td&gt;').append(_inputBarCode)).append($('&lt;td&gt;').append(_shippingTrackingCode))); } $('#tableWrap').append(_tbl); } </code></pre> <p>I have taken a look at several different solutions <a href="https://stackoverflow.com/questions/5617675/help-with-focusing-a-dynamically-created-input">here</a>, <a href="https://stackoverflow.com/questions/9610267/jquery-on-load-of-dynamic-element">here</a>, <a href="http://www.jnorton.co.uk/blog/jquery-load-vs-ready" rel="nofollow noreferrer">here</a> and others on stackoverflow but to no avail.</p> <p>I do not understand the issue here.</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