<html> <head> <title>数组的操作</title> <script type="text/javascript"> function B(){ var names=["zhangsan","lisi","wangwu"]; var name=document.getElementById("name").value; var position = names.indexOf(name); alert(position); if (position >=0) { alert("find"+name+"at position"+position); }else { alert("not find"+name); } } </script> </head> <body> <input type="text" name="name" id="name"> <input type="button" value="dian" onclick="B();"> </body> </html>
时间: 2024-10-10 03:45:01