jQuery selection with dynamic id's

后端 未结 5 1855
余生分开走
余生分开走 2020-12-15 09:56

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

5条回答
  •  心在旅途
    2020-12-15 10:35

    $("input[id^='id_airline_for_']").each(function() {
      var id = parseInt(this.id.replace("id_airline_for_", ""), 10);
      var airline = $("#id_airline_for_" + id);
      var flightNumber = $("#id_flight_number_for_" + id);
      // do stuff with airline and flightNumber s
    });
    

提交回复
热议问题