Javascript examples for jQuery:Array
Replace item in array
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.0/jquery.js"></script> <script type="text/javascript"> function test() {/* w ww .j a v a 2 s. co m*/ var arr = [2, 5]; if (arr[0] < arr[1]) arr.reverse() $("#test").append(arr.join(',') + "<br>"); } </script> </head> <body> <div id="test"></div> <input type="button" value="Click" onclick="test();"> </body> </html>