HTML,SELECT选中后,显示对应内容
推荐于2017-11-28
展开全部
<div style="width:900px; height:500px; margin:0 auto; background:yellow;">
<select name="select" id="select" onchange="羡凯早b();">
<option value="0" >请选择</option>
<option value ="1">二环北路</option>
</select>
<span id="c0" style="display:none;">沃尔玛</span>
<span id="c1" style="display:none;">2</span>
<span id="c2" style="display:none;">38</span>
离兄雀你最近的超市:<span id="a0" style="color:red"></span>
如果你乘公交车,将花费<span id="a1" style="color:red"></span>用掉你<span id="a2" style="color:red"></span>
</div>
<script language="javascript">
function b(){
var values=$("#select").val();
if(values==1){
for(i=0;i<=2;i++){
var j="#c"+i;
var k="#a"+i;
$(k).html($(j).html());
}}else{
for(i=0;i<=2;i++){
var k="#a"孙衫+i;
$(k).html(" ");
}
}
}
</script>
<select name="select" id="select" onchange="羡凯早b();">
<option value="0" >请选择</option>
<option value ="1">二环北路</option>
</select>
<span id="c0" style="display:none;">沃尔玛</span>
<span id="c1" style="display:none;">2</span>
<span id="c2" style="display:none;">38</span>
离兄雀你最近的超市:<span id="a0" style="color:red"></span>
如果你乘公交车,将花费<span id="a1" style="color:red"></span>用掉你<span id="a2" style="color:red"></span>
</div>
<script language="javascript">
function b(){
var values=$("#select").val();
if(values==1){
for(i=0;i<=2;i++){
var j="#c"+i;
var k="#a"+i;
$(k).html($(j).html());
}}else{
for(i=0;i<=2;i++){
var k="#a"孙衫+i;
$(k).html(" ");
}
}
}
</script>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询