Jquery checkbox 选择问题.

霜寒月冷 霜寒月冷 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
<span class='yuan'>数学:3000<input name='kemu' class="jscheck" type='checkbox' title="no2" value="111" /></span>
<span class='yuan'>语文:1000<input name='kemu' class="jscheck" type='checkbox' title="no1" value="22" /></span>
<span class='yuan'>英语:500<input name='kemu' class="jscheck" type='checkbox' title="no3" value="33" /></span>
<input type="button" id="test" />

</body>
</html>

<script type="text/javascript">
$(document).ready(function () {

});
$("#test").click(function () {
var array = '';
$('input[name="kemu"]:checked').each(function () {
array = array + $(this).val()+",";
});
alert(array);
});

</script>


如上 代码只能取出 checkbox 里面的 value 值
并不能取得 span 中的文本值,现想是 遍历中 span 中的checkbox 被选择 则显示 span 中 text 的值。
如果第一、二 个checkbox 被选择 我需要的结果是:数学:3000,语文:1000

...全文

相关推荐

评论 4
收藏 已收藏
分享
返回顶部
霜寒月冷
JavaScript 87,983 成员 224,681 内容