select下拉选中显示对应的div隐藏不相关的div
2024-10-20 01:24:49
<!DOCTYPE html>
<html> <head>
<meta charset="UTF-8">
<title></title>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.js"></script>
</head>
<!-- <script>
$(function() {
//隐藏div $("#shouhou2").hide();
$("#shouhou3").hide();
//给div添加change事件
$("#type").change(function() {
if($(this).val() == 1 ) {
$("#shouhou1").show();
$("#shouhou2").hide();
$("#shouhou3").hide();
} else if($(this).val() == 2 ) {
$("#shouhou2").show();
$("#shouhou1").hide();
$("#shouhou3").hide();
}
else if($(this).val() == 3 ) {
$("#shouhou3").show();
$("#shouhou1").hide();
$("#shouhou2").hide();
}
})
})
</script> --> <body>
<select name="" onchange="select(this)">
<option value="1">题目一</option>
<option value="2">题目二</option>
<option value="3">题目三</option>
<option value="4">题目四</option>
</select> <div> <div id="div1">内容一</div> <div id="div2" style="display:none">内容二</div> <div id="div3" style="display:none">内容三</div> <div id="div4" style="display:none">内容四</div> </div> <script> function select(obj){
$("#div" + obj.value).show().siblings().hide(); }
</script> <!-- <select class="select" size="1" name="type" id="type"> <option value="1">表格</option>
<option value="2">折线图</option>
<option value="3">柱状图</option> </select>
<div id="shouhou1" style>表格区域</div>
<div id="shouhou2" style>折线图区域</div>
<div id="shouhou3" style>柱状图区域</div> -->
</body> </html>
最新文章
- linux安装VMware-tools,
- 小菜学习Winform(四)MDI窗体(附示例)
- UICollectionViewCell选中高亮状态和UIButton的高亮状态和选中状态
- Spring中使用Quartz
- JAVA 集合List,数组,Set,Map,直接的相互转换
- PHP - 5.4 Array dereferencing 数组值
- HttpContext.Current.Session=null问题
- C 语言 ----位运算
- if...else if...else
- FindWindowEx使用方法
- 设置SVN忽略文件和文件夹(文件夹)
- 第5章 不要让线程成为脱缰的野马(Keeping your Threads on Leash) ---线程优先权(Thread priority)
- 重新初始化VS2010
- __x__(13)0906第三天__xhtml 的语法规范
- w3m 在ubuntu中的使用
- const和define的差别
- hbase和zookeeper的安装和部署
- 每天定时备份mysql数据库任务
- return 0;和exit(0);的区别
- 微信小程序自定义事件
热门文章
- new/delete与命名空间
- 函数的练习2——python编程从入门到实践
- centos7编译安装memcached
- 当base-package=";controller.*";时,可见packageSearchPath为";classpath*:controller/*/**/*.class";: 当base-package=";controller.**";时,可见packageSearchPath为";classpath*:controller/**/**/*.class";:
- javascript 同源策略和 JSONP 的工作原理
- 正则表达式";(^|&;)"; ,什么意思?
- mabatis缓存
- nlp-roadmap
- Spring Boot + RabbitMQ 配置参数解释
- Java中关于Math的几个取整方法的区别