jQuery .each to get post meta and subtract from a sum

You don’t need to use jQuery for something like this, it would be better done if you just use php!

So if you store those 3 values in variables you can then do basic math with that data about output the results.

while ($query->have_posts()) :
    $query->the_post();

    $tourNum1 = get_post_meta($post->ID, 'tour_details_number', true);
    $tourNum2 = get_post_meta($post->ID, 'tour_details_number2', true);
    $tourNum3 = get_post_meta($post->ID, 'tour_details_number3', true);
    $total = 20 - ($tourNum1 + $tourNum2 + $tourNum3);

    echo '<li>';

    echo '<div>';
    echo '<span class="num1">';
    echo $tourNum1;
    echo '</span>';
    echo '<span class="num2">';
    echo $tourNum2;
    echo '</span>';
    echo '<span class="num3">';
    echo $tourNum3;
    echo '</span></div>';

    echo '<a href="https://wordpress.stackexchange.com/reserve-items/?add-reserve=";
    echo the_id();
    echo "">';
    echo the_title();
    echo '</a>';
    echo " <span class="count">".$total."</span></li>";
endwhile;