jquery怎么取checkbox的文本值

$("input:checked").each(function(){
str+=$(this).attr("id")+",";
contont+=$(this).attr("value")+",";
});

可以取到已选中的ID, 但取不到已选中的text. text是如何取的?

我试过了$(this).val()取不到, $(this).text()也取不到text…………,

我的checkbox是由后台动态生成的。。生成的html代码:

<span id="Anthem_58__">
<input id="58" type="checkbox" name="58" /><label for="58">体重超过理想体重10%~20%</label></span>

<span id="Anthem_59__"><input id="59" type="checkbox" name="59" /><label for="59">不正常的饮食形态</label></span>


Text 到label里面去了。。。。。 求大侠解决!

  • freedom - 1年前

    <!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>
    <script. language='javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js'></script>
    <script. language='javascript' type='text/javascript'>
    $(document).ready(
        function()
        {
            $(':checkbox').click(function(){
                var $value=$(this).next();
                alert($value.text());
            });
        }
    );
    </script>
    </head>
    <body>
    <<span id="Anthem_58__">
    <input id="58" type="checkbox" name="58" /><label for="58">体重超过理想体重10%~20%</label></span>
    <span id="Anthem_59__"><input id="59" type="checkbox" name="59" /><label for="59">不正常的饮食形态</label></span>
    </body>
    </html>