fmpq.com
源代码:
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Fmpq教程(fmpq.com)</title> </head> <body> <p id="demo">单击按钮显示从位置4开始查找“苹果”的最后一次出现的位置:</p> <button onclick="myFunction()">点我</button> <script> function myFunction(){ var fruits=["香蕉","橙子","苹果","甜瓜","香蕉","橙子","苹果","甜瓜"]; var a=fruits.lastIndexOf("苹果",4) var x=document.getElementById("demo"); x.innerHTML=a; } </script> <p><b>注意:</b>lastIndexOf方法在JavaScript 1.6中被引进,在Internet Explorer 8或更早的版本中不支持。</p> </body> </html>
运行结果