x
1
<p id="demo">单击按钮将数组反转排序。</p>
2
<button onclick="myFunction()">点我</button>
3
<script>
4
var fruits = ["Banana", "Orange", "Apple", "Mango"];
5
6
function myFunction() {
7
fruits.reverse();
8
var x = document.getElementById("demo");
9
x.innerHTML = fruits;
10
}
11
</script>