I've always used a tempClass
to iterate through something and select first child text input. I am having weird issues with this now. I've looked off and on to with no success to find the proper way to do this.
Code Snippet
$( ".inputQuantityUpdate" ).each(function( index ) {
$(this).addClass("tempPtr");
completed = $(".tempPtr :input[type='text']:first").val();
nc = $(".tempPtr :input[type='text']:first").next().val();
if(nc == "NC")nc = 0;
$(this).removeClass("tempPtr");
$(this).parent().remove();
});
My problem is nc and completed is correct for the first iteration, but not after. For some reason this isn't working. What would be the best way to tackle this?
Update: The marked solution worked. I should have posted the other fields I am grabbing because they aren't working. This set of routines works when only 1 element "inputQuantityUpdate" is in the iteration. It blows up when there are multiple. I have a feeling this is some sort of memory issue/syntax misuse on my part. What is the best way to do this if there is data stored in the element like:
function updatesConfirmed(){
$("#confirmInputValues").remove();
$( ".inputQuantityUpdate" ).each(function( index ) {
job = $(this).data("job");
suf = $(this).data("suff");
op = $(this).data("op");
completed = $(":input[type='text']:first", this).val();
nc = $(":input[type='text']:first", this).next().val();
if(nc == "NC")nc = 0;
$(this).parent().remove();
});
}