jquery - Show only values that are set -


i have following script working totally fine. calculation on 2 fields , shows in third field.

     $(function() {      $(document).on('change', 'td.evaluation select', function() {         var gap = parseint($(this).find(':selected').val())- parseint($(this).parents('tr').find('td.mefly').text()) ;          $(this).parents('tr').find('td.gap input:text').val(gap);         if(gap<0){          $(this).parents('tr').find('td.gap input:text').css('background-color','red');         }else  $(this).parents('tr').find('td.gap input:text').css('background-color','#3cb371');       });   }); 

now wanted add script run script on load of page, values have been stored previously. keeps result blank. here tried:

        $(document).ready(function(){              var gap = parseint($("td.evaluation select").find(':selected').val())- parseint($("td.evaluation select").parents('tr').find('td.mefly').text()) ;              $("td.evaluation select").parents('tr').find('td.gap input:text').val(gap);             if(gap<0){                 $("td.evaluation select").parents('tr').find('td.gap input:text').css('background-color','red');             }else  $("td.evaluation select").parents('tr').find('td.gap input:text').css('background-color','#3cb371');          }      )}; 

what did wrong?


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -