jquery - Javascript Each input/element with div? -


i developing dynamic form when user selects item select list different data added form based on selection. these new elements laced within div id of "dyn", tried code below id's of newly added fields , write them console:

$("#dynobject").change(function() {                   alert('inside change function');                   $("#dyn > input").each(function() {                   console.log( $(this).attr("id") );                 });              }); 

the alert code displayed none of id's sent console. each of dynamic elements have id containing string "dynfield" don’t know if can each id contains value?

hope can me issue :)

thanks in advance.

to input elements have id contains string dynfield can use

input[id*="dynfield"]; 

so in example

$('input[id*="dynfield"]').each(function() {     console.log( $(this).attr("id") ); }); 

Comments