练习JavaScript实现梯形乘法表 效果:
表格用html中的table,tr,td,然后利用for语句实现,循环输出行和列,再根据行列的数量进行乘法运算,第一个for循环输出9行, 然后内嵌一个for,在条件表达式中取第一个for循环的值然后进行输出表格运算,为什么要取第一个for循环,因为第一个for循环的次数是梯形排列的 规则,梯形排列的规则是第一行一个格子,第二行二个格子,第三行三个格子,以此类推。
<!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" />
<title>无标题文档</title>
<script type="text/javascript">
var str= "<table border=1 width=500 align=center>";
for(var a=1;a<=9;a++)
{
str +="<tr>";
for(b=1;b<=a;b++)
{
str +="<td>"+a+"×"+b+"="+a*b+"</td>";
}
str +="</tr>";
}
str +="</table>"
document.write(str);
</script>
</head>
<body>
</body>
</html>
练习JavaScript实现梯形乘法表 效果:的更多相关文章
- 练习JavaScript实现梯形乘法表
效果: 表格用html中的table,tr,td,然后利用for语句实现,循环输出行和列,再根据行列的数量进行乘法运算,第一个for循环输出9行,然后内嵌一个for,在条件表达式中取第一个for循环的 ...
- javascript实现九九乘法表
CSS代码部分: <style type="text/css"> table { width: 800px; height: 300px; border-collaps ...
- JavaScript制作九九乘法表
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- javascript 实现九九乘法表
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- JavaScript写九九乘法表
<script language=javascript> for(i=1;i<=9;i++){ for(j=1;j<=9;j++){ document.write (i+&qu ...
- javascript实现99乘法表
for(var i=1; i<=9; i++) { for(var j=1; j<=i;j++) { document.write(i+"x"+i+"=&qu ...
- 1+X证书学习日志——javascript打印九九乘法表(基础算法)
/// 注意要给td加上宽高属性,不然就看不到啦 /// td{ width:100px; height:30px; border:1px solid red; }
- JS实现上下左右对称的九九乘法表
JS实现上下左右对称的九九乘法表 css样式 <style> table{ table-layout:fixed; border-collapse:collapse; } td{ padd ...
- 用JS,打印99乘法表
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...
随机推荐
- dom4j测试
book.xml <?xml version="1.0" encoding="UTF-8"?><books><book>&l ...
- 基于theano的深度卷积神经网络
使用了两个卷积层.一个全连接层和一个softmax分类器. 在测试数据集上正确率可以达到99.22%. 代码参考了neural-networks-and-deep-learning #coding:u ...
- MySQL 5.5: InnoDB Change Buffering
To speed up bulk loading of data, InnoDB implements an insert buffer, a special index in the InnoDB ...
- Windows Azure 生成证书
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64>makecert -sky exchange -r -n &qu ...
- 一个LINUX狂人的语录(个人认为很精辟)
http://blog.chinaunix.net/uid-57160-id-2734431.html?page=2 我已经半年没有使用 Windows 的方式工作了.Linux 高效的完成了我所有的 ...
- pam
http://www.linux-pam.org/ sag(the linux-pam system administrators' guide)翻译(以下是网上别人的翻译,参考一下) http:// ...
- unity, SerializedObject.FindProperty不要写在Editor的OnEnable里,要写在OnInspectorGUI里
如果像下面这样写: using UnityEngine;using System.Collections;using UnityEditor;using System.Collections.Gene ...
- Nancy 简单学习
1. 环境 vs2010 , nancy 2. 需要测试的功能 1. 输出 页面输出简单文本 2. 输出json 数据 3. 操作 1. 创建asp.net 空项目 2. 添加引用Nancy库 使用n ...
- mysql 获取一个表中缺失的最小编号
select count(*),t1.`name` from test_id t1INNER JOIN test_id t2on t1.id >= t2.idgroup by t1.id,t1. ...
- eclipse中web工程新建jsp文件报错:The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path
web工程中新建jsp文件提示:The superclass "javax.servlet.http.HttpServlet" was not found on the Java ...