gpt4 book ai didi

javascript - 通过 jquery 检查所有复选框

转载 作者:行者123 更新时间:2023-11-30 07:02:17 25 4
gpt4 key购买 nike

我想在我的应用程序中通过 jquery 检查所有复选框。我有以下布局:

.row
.col-md-12
= field_set_tag t('car.places')
%input{type: "checkbox", id: "selectAll"}/
= t('car.select_all_locations')

%table.table.table-striped.table-bordered.centered#car_locations
%thead
%tr
%th{width: "200"}= t('cars.select')
%th{width: "300"}= t('cars.your_locations')
%th{width: "200"}= t('cars.location_type')
%th{width: "400"}= t('cars.after_hours_availability')
%tbody
- Location.all.each do |location|
%tr
%td= check_box_tag "car[location_ids][]", location.id, @car.location_ids.include?(location.id), id: "test"
%td= location.name
%td= location_type(location)
%td= after_hours_availability(location)

哪种方式对这件事最好?

最佳答案

试试这个

$(document).on('click','#selectAll',function () {
$(this).closest('table').find('input[type=checkbox]').prop('checked', this.checked);
});

关于javascript - 通过 jquery 检查所有复选框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23129355/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com