Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery selection with dynamic id's
    text
    copied!<p>I have a form that is dynamically generated, and has dynamically generated id's (and potentially classes). The forms are the same but they have the related id tacked on to the end.</p> <p>How can I select each set of inputs and apply code to each one?</p> <p>I was experimenting with $('input[id^=@id_airline_for_]') but could not get it to fly. I suspect I am missing some fundamental jQuery knowledge that is holding me back since I am sure this is a common problem with dynamic forms. </p> <pre><code>&lt;form method='POST'&gt; &lt;label for="id_airline_for_8"&gt;Airline&lt;/label&gt;: &lt;input id="id_airline_for_8" class="arrival_transfer_toggle_8" type="text" maxlength="30" name="airline_for_8"/&gt; &lt;label for="id_flight_number_for_8"&gt;Flight Number&lt;/label&gt;: &lt;input id="id_flight_number_for_8" class="arrival_transfer_toggle_8" type="text" maxlength="30" name="flight_number_for_8"/&gt; &lt;label for="id_airline_for_17"&gt;Airline&lt;/label&gt;: &lt;input id="id_airline_for_17" class="arrival_transfer_toggle_17" type="text" maxlength="30" name="airline_for_17"/&gt; &lt;label for="id_flight_number_for_17"&gt;Flight Number&lt;/label&gt;: &lt;input id="id_flight_number_for_17" class="arrival_transfer_toggle_17" type="text" maxlength="30" name="flight_number_for_17"/&gt; -- snip -- &lt;/form&gt; </code></pre> <p>EDIT: I should update that i want to be able to perform some action when the input is clicked but only for classes with a matching id at the end.</p> <p>To make it easy, lets say I want all inputs with a matching id at the end of the #id to disappear when one is clicked (just for arguments sake).</p>
 

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