Py学习  »  Jquery

jQuery-在表中查找复选框的值

scott • 4 年前 • 761 次点击  

我有以下html:

enter image description here

编辑:

 columns.Command(command => command.Custom("Save").Text("<span class=\"k- 
 icon k-i-check\"></span>Save 
Schedule").Click("saveSchedules")).Width(80).HtmlAttributes(new { @class = 
"text-center" });

我的saveSchedules函数是

 function saveSchedules(e) {

        e.preventDefault();

        var dataItem = $(e).parent('tr').find('.enabled-checkbox').prop('checked');

/// etc

在函数中如何执行此操作?

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/56007
 
761 次点击  
文章 [ 1 ]  |  最新文章 4 年前
ZorgoZ
Reply   •   1 楼
ZorgoZ    4 年前

尝试以下方法:

$('a').on('click', (e) => {
  let v = $(e.currentTarget).closest('tr').find('.enabled-checkbox').prop('checked')
  console.log(v)
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<table>
  <tr>
    <td>TD1</td>
    <td>TD2</td>
    <td>
      <span>
        <input type="checkbox" class="enabled-checkbox" />
      </span>
    </td>
    <td>TD4</td>
    <td>
      <a href="#">Button</a>
    </td>
  </tr>
</table>