[JavaScript] JavaScript数组翻转函数reverse使用范例 →→→→→进入此内容的聊天室

来自 , 2019-04-29, 写在 JavaScript, 查看 122 次.
URL http://www.code666.cn/view/e0f19f64
  1. <!DOCTYPE html>
  2. <html>
  3. <body>
  4.  
  5. <p id="demo">Click the button to reverse the order of the elements in the array.</p>
  6.  
  7. <button onclick="myFunction()">Try it</button>
  8.  
  9. <script>
  10. var fruits = ["Banana", "Orange", "Apple", "Mango"];
  11.  
  12. function myFunction()
  13. {
  14. fruits.reverse();
  15. var x=document.getElementById("demo");
  16. x.innerHTML=fruits;
  17. }
  18. </script>
  19.  
  20. </body>
  21. </html>
  22.  
  23.  
  24. //javascript/7865

回复 "JavaScript数组翻转函数reverse使用范例"

这儿你可以回复上面这条便签

captcha