<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, minimal-ui"> <meta name="screen-orientation" content="portrait"/> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="format-detection" content="telephone=no"> <meta name="full-screen" content="yes"> <meta name="x5-fullscreen" content="true"> <title>input</title> <script src="https://cdn.bootcss.com/jquery/3.1.1/jquery.min.js"></script> <style> </style> </head> <body> <input type="text" class="enter"> <input type="text" class="enter"> <input type="text" class="enter"> <input type="text" class="enter"> <input type="text" class="total"> <script> $('.enter').keyup(function(event) { var total = 0 var num = Number($(this).val()) var val = num === NaN ? 0 : num $('.enter').each(function(data){ if(this == event.target) return total += Number($(this).val()) }) $('.total').val(total + val) }) </script> </body> </html>