標籤:css 選擇 ott span his .text w3c asc img
<!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
利用jQuery選取器快速匹配文檔中的按鈕,並為該按鈕綁定事件處理函數