For some reason this is giving me a hard time and I could use a hand here.
My starting element is this text field:
$('.eachTravColl').on('change', '.progCode input', function(){
For some reason I can't seem to traverse up to the .totalAmt field:
I'm trying to get the value of .totalAmt. Easy, right? Not sure why this is not working.
Things I have tried:
var TotalAmt1 = $(this).parents('li').prevAll('.totalAmt').find('div input').val(); var TotalAmt_1 = $(this).parents('li').prevAll('li').filter(function(){ return $(this).attr('class')==='totalAmt'; }).find('div input').val(); console.log('totalAmt val: '+TotalAmt_1);
I've tried parents(), siblings() and closest() to traverse up. I can return the correct id for the field I need but, it will not return the value for some reason.
Thank so much in advance. I know about 10 of you all that will make short work of this :)
EDIT: this seems to be working, but seems like overkill for this type of thing..
var TotalAmtAttr1 = $(this).parents('li').prevAll('.totalAmt').attr('attr'); var TotalAmt_1 = $(this).parents('li').prevAll('li').filter(function(){ return $(this).attr('attr')===TotalAmtAttr1; }).find('div input').val(); console.log('totalAmt val: '+TotalAmt_1);