分享
 
 
 

javascript手冊-i

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

index property

An integer representing the index of an option in a select object.

语法selectName.options[indexValue].index

selectName is either the value of the NAME attribute of a select object or an element in the elements array.

indexValue is an integer representing an option in a select object.

Property of

options array

描述

The number identifying the position of the option in the selection, starting from zero.

相关

defaultSelected, selected, selectedIndex properties

indexOf method

Returns the index within the calling string object of the first occurrence of the specified value, starting the search at fromIndex.

语法stringName.indexOf(searchValue, [fromIndex])

stringName is any string or a property of an existing object.

searchValue is a string or a property of an existing object, representing the value to search for.

fromIndex is the location within the calling string to start the search from. It can be any integer from 0 to stringName.length - 1 or a property of an existing object.

Method of

string

描述

Characters in a string are indexed from left to right. The index of the first character is 0, and the index of the last character is stringName.length - 1.

If you do not specify a value for fromIndex, JavaScript assumes 0 by default. If searchValue is not found, JavaScript returns -1.

例子The following example uses indexOf and lastIndexOf to locate values in the string "Brave new world". var anyString="Brave new world"

//Displays 8

document.write("<P>The index of the first w from the beginning is " +

anyString.indexOf("w"))

//Displays 10

document.write("<P>The index of the first w from the end is " +

anyString.lastIndexOf("w"))

//Displays 6

document.write("<P>The index of 'new' from the beginning is " +

anyString.indexOf("new"))

//Displays 6

document.write("<P>The index of 'new' from the end is " +

anyString.lastIndexOf("new"))

相关

charAt, lastIndexOf methods

isNaN function

On Unix platforms, evaluates an argument to determine if it is "NaN" (not a number).

语法isNaN(testValue)

testValue is the value you want to evaluate.

描述

The isNaN function is a built-in JavaScript function. It is not a method associated with any object, but is part of the language itself. isNaN is available on Unix platforms only.

On all platforms except Windows, the parseFloat and parseInt functions return "NaN" when they evaluate a value that is not a number. The "NaN" value is not a number in any radix. You can call the isNaN function to determine if the result of parseFloat or parseInt is "NaN". If "NaN" is passed on to arithmetic operations, the operation results will also be "NaN".

The isNaN function returns true or false.

例子

The following example evaluates floatValue to determine if it is a number, then calls a procedure accordingly. floatValue=parseFloat(toFloat)

if isNaN(floatValue) {

notFloat()

} else {

isFloat()

}

相关

parseFloat, parseInt functions

italics method

Causes a string to be italicized as if it were in an <I> tag.

语法stringName.italics()

stringName is any string or a property of an existing object.

Method of

string

描述

Use the italics method with the write or writeln methods to format and display a string in a document.

例子The following example uses string methods to change the formatting of a string: var worldString="Hello, world"

document.write(worldString.blink())

document.write("<P>" + worldString.bold())

document.write("<P>" + worldString.italics())

document.write("<P>" + worldString.strike())

The previous example produces the same output as the following htm: <BLINK>Hello, world</BLINK>

<P><B>Hello, world</B>

<P><I>Hello, world</I>

<P><STRIKE>Hello, world</STRIKE>

相关

blink, bold, strike 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- 王朝網路 版權所有