javascript手冊-i[1]

[入库:2005年8月18日] [更新:2007年3月25日]

本文简介:选择自 longj 的 blog

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()
    }
    

    相关

  • 本文关键:javascript
     

    本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

    go top