244863 Posted September 8, 2010 Share Posted September 8, 2010 Hi, I am new to JQuery and can not get the code below to select multiple siblings, If I remove the siblings for "label" and "#TrsAssignmentName" + nextIndex + "Risk" it works fine???? $(".removeEmployee").live("click", function(removeEvent){ removeEvent.preventDefault(); allEmployees = $(".employee", $("#employees")); index = allEmployees.index($(this).closest(".employee")); nextIndex = index+1; while (allEmployees[nextIndex] !== undefined) { $(allEmployees[nextIndex]) .children("#TrsAssignmentName" + nextIndex + "EmployeeNumber") .attr({ "id" : "TrsAssignmentName" + (nextIndex-1) + "EmployeeNumber", "name" : "data[TrsAssignmentName][" + (nextIndex-1) + "][employee_number]" }) .end() .children("#TrsAssignmentName" + nextIndex + "GcStaffNumber") .attr({ "id" : "TrsAssignmentName" + (nextIndex-1) + "GcStaffNumber", "name" : "data[TrsAssignmentName][" + (nextIndex-1) + "][gc_staff_number]" }) .siblings(".input") .children("label") .attr({ "for" : "TrsAssignmentName" + (nextIndex-1) + "EmployeeName" }) .siblings("input") .attr({ "id" : "TrsAssignmentName" + (nextIndex-1) + "EmployeeName", "name" : "data[TrsAssignmentName][" + (nextIndex-1) + "][employee_name]" }) .siblings("label") .attr({ "for" : "for": "TrsAssignmentName" + employeeIndex + "Risk" }) .siblings("#TrsAssignmentName" + nextIndex + "Risk") .attr({ "id" : "TrsAssignmentName" + (nextIndex-1) + "Risk", "name" : "data[TrsAssignmentName][" + (nextIndex-1) + "][risk]" }) .end() .end() ; nextIndex++; } $(this).closest(".employee").slideUp(250, function() { $(this).remove(); }); }); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.