<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.o ...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript" src="jQuery/版本號自己選"></script> <script type="text/javascript"> $(function(){ $('input[type="button"]').click(function(){ var i = 0; $('input[type="text"]').each(function(){ i += parseInt($(this).val()); }); $("label").text(i); }); $('input:lt(2)') .add("label") .css({ 'border':'none', 'textAlign':'center', 'borderBottom':'solid 1px navy', 'width':'30px' }); }); </script> <title>上機練習</title> </head> <body> <input type="text" value="" />+ <input type="text" value="" /> <input type="button" value="=" /> <label></label> </body> </html>View Code