Javascript的使用技巧大全
1.document.write(""); 输出语句 织梦好,好织梦
2.JS中的注释为// copyright dedecms
3.传统的HTML文档顺序是:document->html->(head,body)
4.一个浏览器窗口中的DOM顺序是:window->(navigator,screen,history,location,document)
5.得到表单中元素的名称和值:document.getElementById("表单中元素的ID号").name(或value)
dedecms.com
6.一个小写转大写的JS: document.getElementById("output").value = document.getElementById("i
织梦内容管理系统
nput").value.toUpperCase(); copyright dedecms
7.JS中的值类型:String,Number,Boolean,Null,Object,Function 本文来自织梦
8.JS中的字符型转换成数值型:parseInt(),parseFloat()
9.JS中的数字转换成字符型:("" 变量) copyright dedecms
10.JS中的取字符串长度是:(length) 织梦好,好织梦
11.JS中的字符与字符相连接使用 号. 内容来自dedecms
12.JS中的比较操作符有:==等于,!=不等于,>,>=,<.<=
织梦好,好织梦
13.JS中声明变量使用:var来进行声明 copyright dedecms
14.JS中的判定语句结构:if(condition){}else{}
内容来自dedecms
15.JS中的循环结构:for([initial expression];[condition];[upadte expression]) {inside loop} 本文来自织梦
16.循环中止的命令是:break 内容来自dedecms
17.JS中的函数定义:function functionName([parameter],...)
18.当文件中出现多个form表单时.可以用document.forms[0],document.forms[1]来代替. 织梦好,好织梦
19.窗口:打开窗口window.open(), 关闭一个窗口:window.close(), 窗口本身:self
20.状态栏的设置:window.status="字符"; copyright dedecms
21.弹出提示信息:window.alert("字符");
织梦内容管理系统
22.弹出确认框:window.confirm();
本文来自织梦
23.弹出输入提示框:window.prompt();
内容来自dedecms
24.指定当前显示链接的位置:window.location.href="URL"
织梦内容管理系统
25.取出窗体中的所有表单的数量:document.forms.length copyright dedecms
26.关闭文档的输出流:document.close();
本文来自织梦
27.字符串追加连接符: = copyright dedecms
28.创建一个文档元素:document.createElement(),document.createTextNode() 织梦好,好织梦
29.得到元素的方法:document.getElementById()
本文来自织梦
30.设置表单中所有文本型的成员的值为空: 织梦内容管理系统
var form = window.document.forms[0]
织梦好,好织梦
for (var i = 0; i if (form.elements.type == "text"){
form.elements.value = "";
本文来自织梦
} 织梦好,好织梦
} copyright dedecms
31.复选按钮在JS中判定是否选中:document.forms[0].checkThis.checked (checked属性代表为是否选中
织梦好,好织梦
返回TRUE或FALSE)

文章评论
共有位Admini5网友发表了评论 查看完整内容