I have an script as following:
$('.Addable').find('input').each(function () {
if ($(this).attr('name')) {
var Name = $(this).attr('name');
var Number = Name;
if (Name.substring(Name.length - 1) == ']') {
var Fi = Name.lastIndexOf("[") + 1;
var Li = Name.lastIndexOf("]");
if (Fi > -1) {
Number = Name.substring(Fi, Li);
if (Number > Indx) {
Number = Number - 1;
$(this).attr('name', Name.substring(0, Fi) + Number + ']');
}
}
}
}
});
So that change Name of inputs perfectly, nut now I need to change all elements not only inputs like selects I think to Replace first line with:
$('.Addable').children().each(function () {
But that not worked, so what is your suggestion to select all child elements?
For ALL descendent elements, you can do what @gdoron suggested. If you’re looking for all form fields in general, not just
input‘s, you can use the:inputselector, which will also matchselect,textarea, etc.: