我得到了要显示的 ckeckboxes,但我无法获得文本框中显示的 ckecked 的值。这是我的整个代码:
<html>
<head>
<script src="jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("#btn1").click(function() {
$v = $("#txt").val();
for(i=0; i<$v; i++)
{var box=$('<input type="checkbox" id="chkbx" name="chkbx" value="Option">Option+$i<br/>');
$("#display").append(box);
}
});
function displayVals()
{
var checkbox = $("#chkbx").val();
$("p").html("<b>Selected Options:</b> " + checkbox.join(" | "));
}
displayVals();
</script>
</head>
<body>
<center>
<table border=0>
<tr>
<td><input type="text box" id="txt" name="text" placeholder="Enter value .."/>
<td><button id="btn1">Create</button>
</tr>
<tr>
<td><div id="display"></div></tr>
<tr>
<td><input type="text box" id="show" name="show" placeholder="Display Selection.."/>
<td><p></p>
</tr>
</center>
</body>
</html>