在Bootstrap / HTML中选中多个框

时间:2019-03-06 21:40:26

标签: html bootstrap-4

如何做到这一点,因此选中一个复选框将同时检查Bootstrap / HTML中的所有其他复选框?

1 个答案:

答案 0 :(得分:1)

它与Bootstrap无关。您需要执行此操作的JavaScript。

示例代码段

const boxHOC = (count, avg_length) => props => (
    <div className="box box-default">
        <div className="box-header with-border">
        <h3 className="box-title">Strings Info</h3>
        <div className="key-details">
            <dl className="dl-horizontal">
                <dt>Count</dt>
                <dd>{count}</dd>
                <dt>Average Length</dt>
                <dd>{avg_length}</dd>
            </dl>
        </div>
        </div>
        <div className="box-header with-border">
            <h3 className="box-title">Strings</h3>
            <div>
                <pre>
                    {props.raw_strings}
                </pre>
            </div>
        </div>
    </div>
);

const OneTwoBox = boxHOC(1, 2);
const ThreeFourBox = boxHOC(3, 4);
function checkall(me) {
  const cbs = document.getElementsByTagName('input')
  for (let i = 0; i < cbs.length; i++) {
    cbs.item(i).checked = me.checked
  }
}