...脚本中创建对应复选框,框后面显示option的value值
发布网友
发布时间:2024-10-20 15:48
我来回答
共2个回答
热心网友
时间:2024-12-01 05:22
<!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">
<title>test</title>
</head>
<body>
<select id="select1">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
<div id="div1"></div>
<script type="text/javascript">
<!--
window.onload=function(){
var oSel = document.getElementById("select1");
var oDiv = document.getElementById("div1");
for(var i=0;i<oSel.length;i++){
var oCk = document.createElement('input');
var oSpan = document.createElement('span');
oCk.type = "checkbox";
var optv = oSel.options[i].value;
oCk.value = optv;
var txt = document.createTextNode(optv);
oSpan.appendChild(txt);
oDiv.appendChild(oCk);
oDiv.appendChild(oSpan);
}
};
//-->
</script>
</body>
</html>
热心网友
时间:2024-12-01 05:23
$("option:selected").val()
$($("option")).each(function(index){ //你的处理代码 })