Commonly used attribute methods in JavaScript include: 1. The comment in JS is [//]; 2. Convert character type to numeric type [parseInt()]; 3. Get the length of the string [length]; 4. Use var to declare variables; 5. Judgment statement structure [if(condition){}else{}].
The operating environment of this tutorial: Windows 7 system, JavaScript version 1.8.5, DELL G3 computer.
Commonly used attribute methods in JavaScript are:
1.document.write(""); Output statement
2. The comment in JS is/ /
3. The traditional HTML document sequence is: document->;html->(head,body)
4. The DOM sequence in a browser window is: window ->;(navigator,screen,history,location,document)
5. Get the name and value of the element in the form: document.getElementById("ID number of the element in the form").name (or value )
6. A lowercase to uppercase JS:
document.getElementById("output").value=document.getElementById("input").value.toUpperCase();
7. Value types in JS: String, Number, Boolean, Null, Object, Function
8. Convert character types into numerical types in JS: parseInt(), parseFloat()
9. Convert numbers in JS to character type: ("" variable)
10. Get the string length in JS: (length)
11.JS Characters are connected with characters using numbers.
12. The comparison operators in JS are: ==Equal,!=Not equal,>;,>;=,<.>
13. Use var to declare variables in JS.
14. Judgment statement structure in JS: if(condition){}else{}
15.JS The loop structure in: for([initial expression];[condition];[upadte expression]) {inside loop}
16. The command to terminate the loop is: break
17. In JS Function definition: function functionName([parameter],...){statement[s]}
18. When multiple form forms appear in the file, you can use document.forms[0],document. forms[1] instead.
19. Window: Open the window window.open(), close a window: window.close(), the window itself: self
20. Status bar Setting: window.status="Character";
21. Pop-up prompt message: window.alert("Character");
22. Pop-up confirmation box: window.confirm();
23. Pop up the input prompt box: window.prompt();
24. Specify the location of the currently displayed link: window.location.href="URL"
25. Get the number of all forms in the form: document.forms.length
26. Close the output stream of the document: document.close();
27. String append connector: =
28. Create a document element: document.createElement(),document.createTextNode()
29. Get the element method: document.getElementById()
30. Set the value of all text members in the form to empty:
var form = window.document.forms[0] for (var i = 0; i<form.elements.length;i ){ if (form.elements.type == "text"){ form.elements.value = ""; } }
31. Determine whether the check button is checked in JS:
document.forms[0].checkThis.checked
(The checked attribute represents whether it is selected and returns TRUE or FALSE )
32. Radio button group (the names of the radio buttons must be the same):
Get the length of the radio button group document.forms[0].groupName.length
33. Checked is also used to determine whether the radio button group is selected.
34. The value of the drop-down list box:
document.forms[0].selectName.options[n].value
(nSometimes the name of the drop-down list box plus .selectedIndex is used to determine Determine the selected value)
35. Definition of string: var myString = new String("This is lightsword");
36. Convert string to uppercase: string.toUpperCase( ); Convert the string to lowercase: string.toLowerCase();
37. Return the position where string 2 appears in string 1: String1.indexOf("String2")!=-1 means there is no Find.
38. Get a character at the specified position in the string: StringA.charAt(9);
39. Get the substring with the specified starting point and end point in the string: stringA. substring(2,6);
40. Math functions:
Math.PI (returns pi), Math.SQRT2 (returns square root), Math.max(value1, value2) returns The
of the two numbers is the most valuable, Math.pow(value1,10) returns the tenth power of value1, Math.round(value1) rounding function,
Math.floor(Math .random()*(n 1)) returns a random number
41. Define date variable: var today = new Date();
42. Date function list:
dateObj.getTime() gets the time, dateObj.getYear() gets the year, dateObj.getFullYear() gets the four-digit year,
dateObj.getMonth () gets the month, dateObj.getDate() gets the day, dateObj.getDay() gets the date,
dateObj.getHours() gets the hours, dateObj.getMinutes() gets the minutes, dateObj.getSeconds() gets seconds,
dateObj.setTime(value)设置时间,dateObj.setYear(val)设置年,
dateObj.setMonth(val)设置月,dateObj.setDate(val)设置日,
dateObj.setDay(val)设置星期几,dateObj.setHours设置小时,dateObj.setMinutes(val)设置分,
dateObj.setSeconds(val)设置秒 [注意:此日期时间从0开始计]
43.FRAME的表示方式:
[window.]frames[n].ObjFuncVarName,frames["frameName"].ObjFuncVarName,frameName.ObjFuncVarName
44.parent代表父亲对象,top代表最顶端对象
45.打开子窗口的父窗口为:opener
46.表示当前所属的位置:this
47.当在超链接中调用JS函数时用:(javascript :)来开头后面加函数名
48.在老的浏览器中不执行此JS:;
49.引用一个文件式的JS:;
50.指定在不支持脚本的浏览器显示的HTML:
51.当超链和onCLICK事件都有时,则老版本的浏览器转向a.html,否则转向b.html.
例:
<a href="a.html" onclick="location.href='b.html';return false">;dfsadf</a>;
52.JS的内建对象有:
Array,Boolean,Date,Error,EvalError,Function,Math,Number,Object,RangeError,
ReferenceError,RegExp,String,SyntaxError,TypeError,URIError
53.JS中的换行:\n
54.窗口全屏大小:
<script>;function fullScreen(){ this.moveTo(0,0);this.outerWidth=screen.availWidth; this.outerHeight=screen.availHeight;}window.maximize=fullScreen;</script>;
55.JS中的all代表其下层的全部元素
56.JS中的焦点顺序:document.getElementByid("表单元素").tabIndex = 1
57.innerHTML的值是表单元素的值:
如
;"how are ;you;"
;,则innerHTML的值就是:how are ;you;58.innerTEXT的值和上面的一样,只不过不会把;这种标记显示出来.
59.contentEditable可设置元素是否可被修改,isContentEditable返回是否可修改的状态.
60.isDisabled判断是否为禁止状态.disabled设置禁止状态
61.length取得长度,返回整型数值
62.addBehavior()是一种JS调用的外部函数文件其扩展名为.htc
63.window.focus()使当前的窗口在所有窗口之前.
64.blur()指失去焦点.与FOCUS()相反.
65.select()指元素为选中状态.
66.防止用户对文本框中输入文本: onfocus="this.blur()"
67.取出该元素在页面中出现的数量: document.all.tags("div(或其它HTML标记符)").length
68.JS中分为两种窗体输出:模态和非模态. window.showModaldialog(),window.showModeless()
69.状态栏文字的设置:
window.status='文字',默认的状态栏文字设置:window.defaultStatus = '文字.';
70.添加到收藏夹:
external.AddFavorite("http://meil.cnblogs.com";,"jaskdlf");
71.JS中遇到脚本错误时不做任何操作:
window.onerror = doNothing; 指定错误句柄的语法为:window.onerror = handleError;
72.JS中指定当前打开窗口的父窗口: window.opener,支持opener.opener...的多重继续.
73.JS中的self指的是当前的窗口
74.JS中状态栏显示内容:window.status="内容"
75.JS中的top指的是框架集中最顶层的框架
76.JS中关闭当前的窗口:window.close();
77.JS中提出是否确认的框:if(confirm("Are you sure?")){alert("ok");}else{alert("Not Ok");}
78.JS中的窗口重定向:window.navigate("http://meil.cnblogs.com";);
79.JS中的打印:window.print()
80.JS中的提示输入框:window.prompt("message","defaultReply");
81.JS中的窗口滚动条:window.scroll(x,y)
82.JS中的窗口滚动到位置:window.scrollby
83.JS中设置时间间隔:setInterval("expr",msecDelay)或setInterval(funcRef,msecDelay)或setTimeout
84.JS中的模态显示在IE4 行,在NN中不行:showModalDialog("URL"[,arguments][,features]);
85.JS中的退出之前使用的句柄:
function verifyClose(){event.returnValue="we really like you and hope you will stay longer.";}} window.=verifyClose;
86.当窗体第一次调用时使用的文件句柄:onload()
87.当窗体关闭时调用的文件句柄:onunload()
88.window.location的属性:
protocol(http:),hostname(www.example.com),port(80),host(www.example.com:80),
pathname("/a/a.html"),hash("#giantGizmo",指跳转到相应的锚记),href(全部的信息)
89.window.location.reload()刷新当前页面.
parent.location.reload()刷新父亲对象(用于框架).
opener.location.reload()刷新父窗口对象(用于单开窗口).
top.location.reload() refreshes the top object (for multiple windows)
90.window.history.back() returns to the previous One page, window.history.forward() returns to the next page,
window.history.go (return to which page, you can also use the visited URL)
91.document. write() does not wrap the output, document.writeln() wraps the output
92.document.body.noWrap=true; prevents the link text from wrapping.
93.Variable name.charAt( Which number), takes the character of the variable.
94. "abc".charCodeAt (what number), returns the ASCii code value of the character.
95. String connection: string.concat(string2), or use = to connect
96. Variable.indexOf("Character", starting position), returns the first occurrence position (starting from 0 Calculate)
97.string.lastIndexOf(searchString[,startIndex])The last occurrence position.
98.string.match(regExpression), determine whether the characters match.
99.string.replace(regExpression,replaceString) replaces the existing string.
100.string.split(separator) returns an array to store the value.
101.string.substr (start[,length]) takes the string from the digit to the specified length.
102.string.toLowerCase() makes the string all lowercase.
103.string. toUpperCase() makes all characters uppercase.
104.parseInt(string[,radix(representing base)]) is forced to be converted to an integer type.
105.parseFloat(string[, radix]) is forced to convert to a floating point type.
106.isNaN (variable): Test whether it is a numeric type.
107. Keywords for defining constants: const, keywords for defining variables :var
Related free learning recommendations: javascript video tutorial
The above is the detailed content of What are the commonly used attribute methods in JavaScript?. For more information, please follow other related articles on the PHP Chinese website!

去掉重复并排序的方法:1、使用“Array.from(new Set(arr))”或者“[…new Set(arr)]”语句,去掉数组中的重复元素,返回去重后的新数组;2、利用sort()对去重数组进行排序,语法“去重数组.sort()”。

本篇文章给大家带来了关于JavaScript的相关知识,其中主要介绍了关于Symbol类型、隐藏属性及全局注册表的相关问题,包括了Symbol类型的描述、Symbol不会隐式转字符串等问题,下面一起来看一下,希望对大家有帮助。

怎么制作文字轮播与图片轮播?大家第一想到的是不是利用js,其实利用纯CSS也能实现文字轮播与图片轮播,下面来看看实现方法,希望对大家有所帮助!

本篇文章给大家带来了关于JavaScript的相关知识,其中主要介绍了关于对象的构造函数和new操作符,构造函数是所有对象的成员方法中,最早被调用的那个,下面一起来看一下吧,希望对大家有帮助。

本篇文章给大家带来了关于JavaScript的相关知识,其中主要介绍了关于面向对象的相关问题,包括了属性描述符、数据描述符、存取描述符等等内容,下面一起来看一下,希望对大家有帮助。

方法:1、利用“点击元素对象.unbind("click");”方法,该方法可以移除被选元素的事件处理程序;2、利用“点击元素对象.off("click");”方法,该方法可以移除通过on()方法添加的事件处理程序。

本篇文章给大家带来了关于JavaScript的相关知识,其中主要介绍了关于BOM操作的相关问题,包括了window对象的常见事件、JavaScript执行机制等等相关内容,下面一起来看一下,希望对大家有帮助。

foreach不是es6的方法。foreach是es3中一个遍历数组的方法,可以调用数组的每个元素,并将元素传给回调函数进行处理,语法“array.forEach(function(当前元素,索引,数组){...})”;该方法不处理空数组。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Atom editor mac version download
The most popular open source editor
