<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
<!--
$(document).ready(function(){
$("#title").change(function() {
$(".postItem").hide();
var selectedIndex = $("#title").get(0).selectedIndex;
$($(".postItem").get(selectedIndex )).show();
});
});
-->
</script>
</head>
<body>
<select class="selStyle1" id="title" name="title">
<option>新闻</option>
<option>娱乐</option>
<option>体育</option>
</select>
<div class="postItem">新闻新闻新闻新闻新闻新闻</div>
<div class="postItem">娱乐娱乐娱乐娱乐娱乐娱乐</div>
<div class="postItem">体育体育体育体育体育体育</div>
</body>
</html>问题:默认选择的是新闻 理应只显示“新闻新闻新闻新闻新闻新闻” 但是其他两个也显示了 怎样半呢?
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
<!--
$(document).ready(function(){
$("#title").change(function() {
$(".postItem").hide();
var selectedIndex = $("#title").get(0).selectedIndex;
$($(".postItem").get(selectedIndex )).show();
});
});
-->
</script>
</head>
<body>
<select class="selStyle1" id="title" name="title">
<option>新闻</option>
<option>娱乐</option>
<option>体育</option>
</select>
<div class="postItem">新闻新闻新闻新闻新闻新闻</div>
<div class="postItem">娱乐娱乐娱乐娱乐娱乐娱乐</div>
<div class="postItem">体育体育体育体育体育体育</div>
</body>
</html>问题:默认选择的是新闻 理应只显示“新闻新闻新闻新闻新闻新闻” 但是其他两个也显示了 怎样半呢?
解决方案 »
- javascript使用了嵌套函数后,嵌套函数的鼠标点击事件在其它浏览器上没有用了
- Microsoft JScript 运行时错误: 'null' 为空或不是对象
- 下列选项中,对于JSP的执行过程描述正确的是()
- Jquery thickbox tb_show
- js 删除tr出现问题
- 像新浪右下脚弹出的视频窗口是怎么做的。
- 同样的代码放到函数里面可以执行,拿出来就不行了
- 请问有什么好的屏蔽f5的方法,谢谢!!
- 请教窗口大小调整的问题
- <frameset><frame name...></frameset>是什么意思?谢谢!!!
- ExtJS4 动态加载js,而不是一个类文件
- 菜鸟问通过id设置背景颜色
$(document).ready(function(){
$('.postItem:gt(0)').hide()
$("#title").change(function() {
$(".postItem").hide();
var selectedIndex = $("#title").get(0).selectedIndex;
$($(".postItem").get(selectedIndex )).show();
});
});
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
<!--
$(document).ready(function(){
$('.postItem:gt(0)').hide()
$("#title").change(function() {
$(".postItem").hide();
var selectedIndex = $("#title").get(0).selectedIndex;
$($(".postItem").get(selectedIndex )).show();
});
});
-->
</script>
</head>
<body>
<select class="selStyle1" id="title" name="title">
<option>新闻</option>
<option>娱乐</option>
<option>体育</option>
</select>
<div class="postItem">新闻新闻新闻新闻新闻新闻</div>
<div class="postItem">娱乐娱乐娱乐娱乐娱乐娱乐</div>
<div class="postItem">体育体育体育体育体育体育</div>
</body>
</html>