分享
 
 
 

javascript手冊-e

王朝html/css/js·作者佚名  2006-01-08
窄屏简体版  字體: |||超大  

E property

Euler's constant and the base of natural logarithms, approximately 2.718.

语法Math.E

Property of

Math

描述

Because E is a constant, it is a read-only property of Math.

例子

The following example displays Euler's constant: document.write("Euler's constant is " + Math.E)

See also

LN2, LN10, LOG2E, LOG10E, PI, SQRT1_2, SQRT2 properties

elements array

An array of objects corresponding to form elements (such as checkbox, radio, and text objects) in source order.

语法1. formName.elements[index]

2. formName.elements.length

formName is either the name of a form or an element in the forms array.

index is an integer representing an object on a form.

Property of

form

描述

You can reference a form's elements in your code by using the elements array. This array contains an entry for each object (button, checkbox, hidden, password, radio, reset, select, submit, text, or textarea object) in a form in source order. For example, if a form has a text field and two checkboxes, these elements are reflected as formName.elements[0], formName.elements[1], and formName.elements[2].

Although you can also reference a form's elements by using the element's name (from the NAME attribute), the elements array provides a way to reference form objects programatically without using their names. For example, if the first object on the userInfo form is the userName text object, you can evaluate it in either of the following ways: userInfo.userName.value

userInfo.elements[0].value

To obtain the number of elements on a form, use the length property: formName.elements.length. Each radio button in a radio object appears as a separate element in the elements array.

Elements in the elements array are read-only. For example, the statement formName.elements[0]="music" has no effect.

The value of each element in the elements array is the full htm statement for the object.

Properties

length reflects the number of elements on a form

例子

See the 例子 for the name property.

See also

form object

elements property

An array of objects corresponding to form elements (such as checkbox, radio, and text objects) in source order. See elements array.

encoding property

A string specifying the MIME encoding of the form.

语法formName.encoding

formName is either the name of a form or an element in the forms array.

Property of

form

描述

The encoding property initially reflects the ENCTYPE attribute of the <FORM> tag; however, setting encoding overrides the ENCTYPE attribute.

You can set the encoding property at any time.

Certain values of the encoding property may require specific values for other form properties. See RFC 1867 for more information.

例子

The following function returns the value of the musicForm encoding property: function getEncoding() {

return document.musicForm.encoding

}

See also

action, method, target properties

escape function

Returns the ASCII encoding of an argument in the ISO Latin-1 character set.

语法escape("string")

string is a non-alphanumeric string in the ISO Latin-1 character set, or a property of an existing object.

描述

The escape function is not a method associated with any object, but is part of the language itself.

The value returned by the escape function is a string of the form "%xx", where xx is the ASCII encoding of a character in the argument. If you pass the escape function an alphanumeric character, the escape function returns the same character.

例子

The following example returns "%26" escape("&")

The following example returns "%21%23" escape("!#")

See also

unescape function

eval function

The eval function evaluates a string and returns a value.

语法eval(string)

string is any string representing a JavaScript expression, statement, or sequence of statements. The expression can include variables and properties of existing objects.

描述

The eval function is a built-in JavaScript function. It is not a method associated with any object, but is part of the language itself.

The argument of the eval function is a string. Do not call eval to evaluate an arithmetic expression. JavaScript evaluates arithmetic expressions automatically. If the argument represents an expression, eval evaluates the expression. If the argument represents one or more JavaScript statements, eval performs the statements.

If you construct an arithmetic expression as a string, you can use eval to evaluate it at a later time. For example, suppose you have a variable x. You can postpone evaluation of an expression involving x by assigning the string value of the expression, say "3 * x + 2", to a variable, and then calling eval at a later point in your script.

例子

Example 1. Both of the write statements below display 42. The first evaluates the string "x + y + 1", and the second evaluates the string "42". var x = 2

var y = 39

var z = "42"

document.write(eval("x + y + 1"), "<BR>")

document.write(eval(z), "<BR>")

Example 2. In the following example, the getFieldName(n) function returns the name of the nth form element as a string. The first statement assigns the string value of the third form element to the variable field. The second statement uses eval to display the value of the form element. var field = getFieldName(3)

document.write("The field named ", field, " has value of ", eval(field + ".value"))

Example 3. The following example uses eval to evaluate the string str. This string consists of JavaScript statements that opens an alert dialog box and assigns z a value of 42 if x is five, and assigns zero to z otherwise. When the second statement is executed, eval will cause these statements to be performed, and it will also evaluate the set of statements and return the value that is assigned to z. var str = "if (x == 5) {alert('z is 42'); z = 42;} else z = 0; "

document.write("<P>z is ", eval(str))

Example 4. In the following example, the setValue() function uses eval to assign the value of the variable newValue to the text field textObject. function setValue (textObject, newValue) {

eval ("document.forms[0]." + textObject + ".value") = newValue

}

exp method

Returns enumber, where number is the argument, and e is Euler's constant, the base of the natural logarithms.

语法Math.exp(number)

number is any numeric expression or a property of an existing object.

Method of

Math

例子//Displays the value 2.718281828459045

document.write("The value of e<SUP>1</SUP> is " + Math.exp(1))

See also

log, pow methods

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有