</p> <form> <select name="mySelect" size="3"> <option>Apple</option> <option>Banana</option> <option>Orange</option> </select> <input type="button" onclick="formAction()" value="Select multiple"> </form> </body>
</html>
返回所选列表的文本值
<html> <head> <script type="text/javascript"> function getText() { var x=document.getElementById("mySelect") alert(x.options[x.selectedIndex].text) } </script> </head>
<body> <form> Select your favorite fruit: <select id="mySelect"> <option>Apple</option> <option>Orange</option> <option>Pineapple</option> <option>Banana</option> </select> <br /><br /> <input type="button" onclick="getText()" value="Show text of selected fruit"> </form> </body>
</html>
删除列表的项目
<html> <head> <script type="text/javascript"> function formAction() { var x=document.getElementById("mySelect") x.remove(x.selectedIndex) } </script> </head>
<body> <form> <select name="mySelect"> <option>Apple</option> <option>Banana</option> <option>Orange</option> </select> <input type="button" onclick="formAction()" value="Remove option"> </form> </body>
</html>
显示屏幕的信息
<html> <body> <script type="text/javascript"> document.write("Screen resolution: ") document.write(screen.width + "*" + screen.height) document.write("<br />") document.write("Available view area: ") document.write(screen.availWidth + "*" + screen.availHeight) document.write("<br />") document.write("Color depth: ") document.write(screen.colorDepth) document.write("<br />") </script> </body> </html>
表格对象
改变表格的边框
<html> <head> <script type="text/javascript"> function changeBorder() { document.getElementById('myTable').border="10" } </script> </head>
<body> <table border="1" id="myTable">
上一篇:网页制作中表单相关特效整理
下一篇:javascript的键盘控制事件
|