switch使用--查询水果价格案例
2024-09-05 19:17:48
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Document</title>
</head>
<script>
window.onload=function()
{
var txt=document.getElementById("txt");
var btn=document.getElementById("btn");
btn.onclick=function()
{
var val=txt.value; //点击按钮之后才会获取文本框中的值
switch(val)
{
case "苹果" :
alert("1元");break;
case "香蕉":
alert("2元");break;
case "梨":
alert("3元");break;
default:
alert("没有这个水果");
}
}
}
</script>
<body>
<input type="text" id="txt"/>
<button id="btn">查询价格</button>
</body>
</html>
最新文章
- 【PHP夯实基础系列】PHP日期,文件系统等知识点
- php自学提升进阶路线
- Oracle SQL*plus常用的命令和函数
- 让linux中的程序崩溃时生成core文件
- DOS通讯录
- mysql之创建外键报150错误的处理方法
- python装饰器总结
- Apache 多站点(虚拟主机)
- 实例讲解MSSQL日期相加减比大小函数 转
- ajax+XMLHttpRequest里的FormData实现图片异步上传
- 调试大叔V1.0.1(2017.09.01)|http/s接口调试、数据分析程序员辅助开发神器
- scapyd部署出现的问题的解决方案
- Linux学习笔记之Python3的安装以及创建虚拟环境(CentOS)
- spring mvc get请求中文乱码问题
- 1.创建和销毁对象_EJ
- 转:win7下git凭据导致无法clone代码
- 数据库编程加入transaction
- Java知识回顾 (4)Java包装类
- 04 memory structure
- spark mysql读写
热门文章
- 【Leetcode】整数反转
- event.stopPropagation()和event.preventDefault(),return false的区别
- Http请求详解(转)----请求+响应各字段详解
- NOIP2009靶形数独(暴搜)
- 测试常用shell命令
- android UI设计及开发
- code first System.Data.Entity.Infrastructure.CommitFailedException: An error was reported while committing a database transaction but it could not be determined whether the transaction succeeded
- 2、electron进程
- ubuntu的无线网无法连上
- freemarker程序开发