Prev Demo
Returning Selected Elements Using Negative Input Values
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> </head> <body> <p>Click the below to select the elements from the end.</p> <input type="button" onclick="myValue()" value="Return"/> <p id="myId"></p> <script> function myValue() { var a = ["India", "Mumbai", "Pakisthan", "Karachi", "Malaysia", "Abudhabi"]; var b = a.slice(-4, -1); document.getElementById("myId").innerHTML = b; } </script> </body> </html>
Note: We DO NOT save your trial code in our database.
Output