运行结果尺寸: 300 x 150
x
 
<!DOCTYPE html>
<html>
<body>
<p>单击按钮显示元素“Apple”的最后位置:</p>
<button onclick="myFunction()">试一试</button>
<p id="demo"></p>
<script>
function myFunction() {
  var fruits = ["香蕉","橙子","苹果","芒果"];
  var a = fruits.lastIndexOf("Apple");
  var x = document.getElementById("demo");
  x.innerHTML = a;
}
</script>
<p><b>注意:</b>lastIndexOf 方法是在 JavaScript 1.6 中引入的,在 Internet Explorer 8 及更早版本中不起作用。</p>
</body>
</html>
×

报个问题: