通过这个例子思考下列问题
• 1 怎么得到文档中的元素?
答:使用document.getElementById("ID")
• 怎么的到用户的输入,从输入元素里面.
答:通过元素的.value获得
• 怎么设置文档中某一个元素的内容
答:通过 elment.innerHTML ="";
• 怎么存储数据在浏览器下.
答:用window.localStorage,擦这个html5才支持吧
• 怎么用脚本请求页面.答:用XMLHttpRequest对象。
• 如何用<canvas> 元素画图.答:var g = canvas.getContext("2d");
g.beginPath(),moveto,endPath(); g.stroke(); g.fillRect(); g.fillText()等。
例子: 贷款计算器 22
47 48 49 50 241 242
1 2 3 4JavaScript Loan Calculator 5 11 12 13 21
Enter Loan Data: | 2324 | Loan Balance, Cumulative Equity, and Interest Payments |
---|---|---|
Amount of the loan ($): | 2627 | 28 |
Annual interest (%): | 30||
Repayment period (years): | 3233 | |
Zipcode (to find lenders): | 3435 | |
Approximate Payments: | 36||
Monthly payment: | 38$ | |
Total payment: | 40$ | |
Total interest: | 42$ | |
Sponsors: | 44 Apply for your loan with one of these fine lenders: 45 |