Bootstrap table check uncheck rows by array of values

html 复制代码
<link href="https://unpkg.com/bootstrap-table@1.22.1/dist/bootstrap-table.min.css" rel="stylesheet">

<script src="https://unpkg.com/bootstrap-table@1.22.1/dist/bootstrap-table.min.js"></script>

<div id="toolbar">
  <button id="button" class="btn btn-secondary">checkBy</button>
  <button id="button2" class="btn btn-secondary">uncheckBy</button>
</div>
<table
  id="table"
  data-toggle="table"
  data-toolbar="#toolbar"
  data-height="460"
  data-url="json/data1.json">
  <thead>
    <tr>
      <th data-field="state" data-checkbox="true"></th>
      <th data-field="id">ID</th>
      <th data-field="name">Item Name</th>
      <th data-field="price">Item Price</th>
    </tr>
  </thead>
</table>

<script>
  var $table = $('#table')
  var $button = $('#button')
  var $button2 = $('#button2')

  $(function() {
    $button.click(function () {
      $table.bootstrapTable('checkBy', {field: 'id', values: [1, 2, 3]})
    })
    $button2.click(function () {
      $table.bootstrapTable('uncheckBy', {field: 'id', values: [1, 2, 3]})
    })
  })
</script>
相关推荐
yuanyxh4 分钟前
Mac 软件推荐
前端·javascript·程序员
万少9 分钟前
AtomCode开发微信小程序《谁去呀》 全流程
前端·javascript·后端
某人辛木24 分钟前
Web自动化测试
前端·python·pycharm·pytest
Kagol1 小时前
Superpowers GSD gstack AgentSkills深度测评
前端·人工智能
excel2 小时前
JavaScript 字符串与模板字面量:从表象到本质理解
前端
京东云开发者2 小时前
当AI成为导演-如何用AI创作动漫短剧
前端
李白的天不白3 小时前
使用 SmartAdmin 进行前后端开发
java·前端
乘风gg3 小时前
🤡PUA AI Coding 工具 的 10 条终极语录
前端·ai编程·claude
学Linux的语莫3 小时前
Vue 3 入门教程
前端·javascript·vue.js
怕浪猫3 小时前
第一章、Chrome DevTools Protocol (CDP) 详解
前端·javascript·chrome