Chaning Ids of radio buttons in radiobutton groups

Chaning Ids of radio buttons in radiobutton groups

Hi,
I have a button called Add Quantity. When it is clicked, a div is added with a textbox for Amount, a button called Remove and two radio buttons called And & Or. When Add Quantity button is pressed another div is added. So forth and so on. When Remove button is clicked, I'm removing the div and then I change the ids and names of each control in these divs so that indexes are sequential. E.g. if div Amount3 is deleted then I rename the divs and controls within it. I'm having trouble renaming radio buttons within each group.
e.g. I have 5 divs. Each div has two radio buttons.  I delete div 3, then I want to change the id's and names and here is what I'm doing but it is not working

  1.                var index = 0;
  2.                $("input[id$=__AndOr]]").each(function (item) {
                        // update the "id" properties
                        $("input[id$=__AndOr]").prop("id", "Max_" + index + "__AndOr");
                        $("input[id$=__AndOr]").prop("name", "Max[" + index + "].AndOr");
                        index++;
                    });
Any idea what mistake I'm making?

Joe