<select name="select" >
<option>北京</option>
<option>天津</option>
<option>上海</option>
<option >其他</option>
</select>
<input id='b' value='3253425'/>
<input id='a' />
根据上面的代码使我选择其他时就出现id=a的input标签,选择北京、天津、上海出现id=b的input标签,默认显示id=b的input标签
额。。。不懂。。小白。。。能不能写清楚点?
追答
About
$(function(){
$("select[name=select]").bind("change",function(){
if($(this).val()=="其他"){
$("#a").show();
$("#b").hide();
}else{
$("#a").hide();
$("#b").show();
}
});
});
北京
天津
上海
其他
额。。我就是要js控制啊。。
追答
function change(){
var valueObj = document.getElementById('selectID');
var AInput = document.getElementById('a');
var valueIndex = valueObj.selectedIndex;
var value = valueObj.options[valueIndex].value;
var text = valueObj.options[valueIndex].text;
//alert(value);
if(value==-1){
AInput.style.display = "block";
}else{
AInput.style.display = "none";
}
}
北京
天津
上海
其他
city:
other:
这个可以实现你说的,界面你自己调试,如果有问题,请留言。
额、。。我需要2个input标签在同一个地方显示,也就是默认显示的是id=b的input标签,当我选择其他时就把id=b的input标签替换为id=a的input标签