日期:2014-05-16  浏览次数:20614 次

以下程序实现后,<div id="myys"></div>里的按钮可以点击,但没法选中,求解
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<style type="text/css">
ul{list-style-type:none;}
ul li{float:left;display:inline;margin-right:5px;width:auto;overflow:hidden;}
ul li a{display:block;border:1px solid #CCCCCC;padding:5px 6px 5px 6px;margin:1px;}
ul li a:hover{border:2px solid #FF6701;margin:0px;}
.select{}
.select a{border:2px solid #FF6701;margin:0px;background:url(images/2010083011191628.gif) no-repeat no-repeat right bottom;}
</style>
<SCRIPT LANGUAGE="JavaScript">
window.onload=function(){
 var color = new Select("color",{
  Radio :true , //是否为单选,默认为true,如果设置为true,Default,Max选项将失效
  OnClick:function(selected){
  document.form.color.value = selected.join(",")
  }
 });
}

function Rchange(value){
var ops = new Array();
ops[1]="<ul id=\"color\"><li dataValue=\"红\"><a href=\"javascript:void(0)\">红色</a></li><li dataValue=\"黑\"><a href=\"javascript:void(0)\">黑色</a></li><ul>";
document.getElementById('myys').innerHTML=ops[1];
}
</script>
<body>
<a href="javascript:void(0)" onclick="Rchange(1,'myys')">点击出现</a>
<br><br>
<div id="myys"></div>
</body>
</html>

------解决方案--------------------
HTML code

<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<style type="text/css">
ul{list-style-type:none;}
ul li{float:left;display:inline;margin-right:5px;width:auto;overflow:hidden;}
ul li a{display:block;border:1px solid #CCCCCC;padding:5px 6px 5px 6px;margin:1px;}
ul li a:hover{border:2px solid #FF6701;margin:0px;}
.select{}
.select a{border:2px solid #FF6701;margin:0px;background:url(images/2010083011191628.gif) no-repeat no-repeat right bottom;}
</style>
<SCRIPT LANGUAGE="JavaScript">
window.onload=function(){
 var color = new Select("color",{
  Radio :true , //是否为单选,默认为true,如果设置为true,Default,Max选项将失效
  OnClick:function(selected){
  document.form.color.value = selected.join(",")
  }
 });
}

function Rchange(value){
var ops = new Array();
ops[1]="<ul id=\"color\"><li dataValue=\"红\" onclick='set(this)'><a href=\"javascript:void(0)\">红色</a></li><li dataValue=\"黑\" onclick='set(this)'><a href=\"javascript:void(0)\">黑色</a></li><ul>";
document.getElementById('myys').innerHTML=ops[1];
}
var cur;
function set(t){
    if(cur){
        cur.className = ''
    }
    t.className = 'select';
    cur = t;
}

</script>
<body>
<a href="javascript:void(0)" onclick="Rchange(1,'myys')">点击出现</a>
<br><br>
<div id="myys"></div>
</body>
</html>