web网页里有单选框和ok按钮,用js和html实现单击ok按钮后单选框消失,在单击ok按钮单选框出现。。反复下去 JavaScriptHTMLWeb
解决方案 »
- 发布JS游戏框架JYG,附自己开发的几款JS小游戏
- Extjs 几个iframe模式的window间如何互相操作?
- 新手求教,如何在一个页面共用一个JS特效。
- javascript能屏蔽alt键吗?ie8中,让它不执行菜单聚焦
- kindeditor 在线编辑器 死活有个问题看不懂 求助
- 为什么我提交的表单有问题???
- jquery中$(document).on的一些疑惑
- 关于框架的问题 !大家来帮忙!不胜感激!(在线等候)
- 关于select和其他相关select的现实和隐藏问题
- 如何把img控件中的图片转化成二进制
- 谁帮忙看一下jQuery ScrollPagination
- 大家帮忙看一下 调用js的这个函数为什么不出来
<!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=utf-8" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<title>无标题文档</title>
</head><body>
<div id="sexoption">
<input type="radio" name="sex" value="1" />body
<input type="radio" name="sex" value="2" />girl
</div>
<input type="button" id="btn" value="choose" /><script type="text/javascript">
jQuery(function ($) {
$("#btn").click(function () {
if($('#sexoption').css('display')=='block'){
$('#sexoption').hide();
}else{
$('#sexoption').show();
}
});
});
</script>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<title>无标题文档</title>
</head>
<body>
<div id="sexoption">
<input type="radio" name="sex" value="1" />body
<input type="radio" name="sex" value="2" />girl
</div>
<input type="button" id="btn" value="choose" onclick="changeState()"/>
<script type="text/javascript">
function changeState(){
var sexoption=document.getElementById("sexoption");
sexoption.style.display=sexoption.style.display=="none"?"":"none";
}
</script>
</body>
</html>
document.getElementById('btn').onclick=function(){
var s=document.getElementById('sexoption');
var status=(s.style.display == 'none');
if(status){
document.getElementById( 'sexoption' ).style.display="block";
}else{
document.getElementById( 'sexoption' ).style.display="none" ;
}
}
<!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=utf-8" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<title>无标题文档</title>
</head><body>
<select name="sex" id="sex" size="1">
<option value="1">body</option>
<option value="2">girl</option>
</select>
<div id="sexoption">
<!--<input type="radio" name="sex" value="1" />body
<input type="radio" name="sex" value="2" />girl-->
</div><input type="button" id="btn" value="choose" /><script type="text/javascript">
/*jQuery(function ($) {
$("#btn").click(function () {
if($('#sexoption').css('display')=='block'){
$('#sexoption').hide();
}else{
$('#sexoption').show();
}
});
});*/
document.getElementById('btn').onclick=function(){
var s=document.getElementById('sex');
var rehtml="";
var radioName=s.getAttribute('name');
//alert(radioName);
for(var i=0;i<s.options.length;i++){
rehtml+="<input type=\"radio\" name=\""+radioName+"\" value=\""+ s.options[i].value+"\"/>"+s.options[i].text;
}
var racontainer=document.getElementById('sexoption');
if(racontainer.getElementsByTagName('input').length>1){
document.getElementById('sexoption').innerHTML="";
}else{
document.getElementById('sexoption').innerHTML= rehtml;
}
/*var s=document.getElementById('sexoption');
var status=(s.style.display == 'none');
if(status){
document.getElementById( 'sexoption' ).style.display="block";
}else{
document.getElementById( 'sexoption' ).style.display="none" ;
}*/
}
</script>
</body>
</html>