|
|
|
|
для: ferz
(10.05.2006 в 18:02)
|
| stringName.indexOf (searchValue [, fromIndex])
stringName - любая строка или свойство существующего объекта.
searchValue - строка или свойство существующего объекта, представляющие значение, которое нужно искать.
fromIndex - поиск начинается с этой позиции. Это может быть любое целое число от 0 до stringName.length - 1 или свойство существующего объекта.
Следующий пример использует indexOf, и lastIndexOf, чтобы разместить значение в строке"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"))
|
| |
|
|