繁体   English   中英

jQuery或Javascript通过单选按钮和标签的组合在表格单元格中获取标签文本

[英]JQuery or Javascript to get label text in table cell with combination of radio button and label

我有一个表格,第一栏包含单选按钮和标签的组合。 请不要建议我将文本放在单选按钮中,因为我有一个函数会在每行的标签上放置值,因此无法合并它。

HTML:

<table id="template" style="display:none;">
    <tr>
        <td class="hidden"></td>
        <td>
            <input type="radio" name="rbDefaultPrice" class="radio" />
            <label style="font-size: 1em" class="price"></label>
        </td>
        <td class="startdate"></td>
        <td class="enddate"></td>
    </tr>
</table>

脚本:

$("#template").click(function (e) {
    //JQuery or JS to get label text value
});

选择标签,然后获取html。

$("#template").click(function (e) {
     //console.log or whatever you want to do with it
     console.log(  $('.price').html()  )
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM