I have a form where you have to enter properties of House, like name,number etc. In the same form they will mention for how many number of houses you have to enter these properties.Based on the number of house i'm generating the input fields for each house like this.
var text1 = '<input type="text" min="1" id="houseNo[' + i + ']" class="Houseno form-control" name="projectConfigurationDetails[' + i + '].houseNo">';
After that when i'm trying read value like this
$('#houseNo[0]').attr('name');
its giving me undefined
After some trail and errors we changed id
to "houseNo' + i + '"
by removing square brackets.Then
$('#houseNo0').attr('name');
That is giving perfect value.Are square Brackets making Jquery think like that is some selector pattern but we are mentioning #
so that is id
.
If i'm missing some thing please educate me.