Jump to content

jquery can not select multiple .siblings


244863

Recommended Posts

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();

});

});

Link to comment
https://forums.phpfreaks.com/topic/212862-jquery-can-not-select-multiple-siblings/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.