我想实现 就是:
假如select框(有N项) 值发生变化,当单击第一项,页面也就对应发生相应的变化,就如页面的内容 是随着select框的值是相对应的 我点哪个select值 ,页面就显示哪一块的内容。然后提交表单。就是这个 我觉得用jQuery实现 应该不是很难,
忘大家给点思路 或者小例子 哈哈
假如select框(有N项) 值发生变化,当单击第一项,页面也就对应发生相应的变化,就如页面的内容 是随着select框的值是相对应的 我点哪个select值 ,页面就显示哪一块的内容。然后提交表单。就是这个 我觉得用jQuery实现 应该不是很难,
忘大家给点思路 或者小例子 哈哈
//your process
});
$("#selectId").change(function () {
$("form").sumbit();
$("body").html($(this).find("selected").val());
});
<option>1</option>
<option>2</option>
<option>3</option>
</select>$('#test').change(function(){
var text = $(this).find('option:selected').val();
alert(text);
});
问题 我想实现 页面的内容随之变化,选择不同的select值的时候 页面的内容 要显示不一样的东西
没有被单击的项,页面的内容 还是影藏的,就是点哪一项 显示对应的页面
怎么确定好关系。我的select框至少十几项,不会让我重复写十几遍的 hide show 吧?
所以 想请教有没有好的方法??????
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>测试分页</title>
</head>
<script src="js/jquery.min.js"></script>
<script>
$(function(){
$("#select").change(function(){
$("option").each(function(){
if($(this).is(":selected")){
var text = $(this).text();
var url = text+".html";
alert(url)
$("#test").attr("src",url);
}
});
});
});
</script>
<body>
<select id="select">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
<iframe id="test" style="width:200px; height:200px"></iframe>
</body>
</html>
$("#selectId").change(function () {
});
不过 如果我是 不同的div块呢?
我想让 单击时候那个div的页面内容 才显示,而其它全是影藏的
单击一个 显示一块
可否写下具体的代码呢?
我也刚接触没多久 只是知道jQuery比较方便 呵呵
真是麻烦大家了
<option value='diva'>a</option>
<option value='divb'>b</option>
</select>
#diva{height:100px;width:100px; background-color:Blue;}
#divb{height:100px;width:100px; background-color:red;}
$(function() {
$("#diva").hide();
$("#divb").hide();
});
function ab() {
var ssObj = document.getElementById("ss");
var divId = ssObj.children[ssObj.selectedIndex].value;
$("#" + divId).show();
}