1.使用js拼接html的内容:
申明一个变量tableHtml
document.write(tableHtml);
var tableHtml="<table>";
var tr="<tr>";
tr="</tr>";
2、js 函数的格式:
function 函数名([ 参数列表]){
程序代码
[返回值]
}
3.js中的运算符逻辑比较
= (x = 3),
+= ( x+=3 等效于x = x+3),
-= (x-=3 等效于x = x-3),
*= (x*=3 等效于x = x*3),
/= (x/=3 等效于 x= x/3)
%= (x%=3 等效于 x= x%3
== :代表相等(它只比较内容,不比较类型)
例如:console.log(2=="2");
===:绝对相等(先比较类型,再比较内容)
例如:console.log(2==="2");
!=:不等(比较内容,不比较类型)
!==:绝对不等
4.js 的三种书写方式
第一种:写在a标签的href里面 |
<a href="javascript:alert('点你就点你');">点我,点我...</a> |
第二种:使用script标签 |
<!-- 我们就可以在这个标签里面写js代码 --> <script type="text/javascript"> alert("不点我也来..."); </script> |
第三种方式:使用script标签 进行外连接 |
<script type="text/javascript" src="index.js"></script> ------------------------------------- 还需要一个js文件 |