简体   繁体   中英

jquery Checkbox Selection to manipulate a table of row

I need to select the header checkbox when all the rows are selected.

I used logic to keep a count of the number of rows checked if it's equal to row_count,I need to select the header checkbox

The problem is I cannot access the header checkbox through DOM because of the browser restriction I'm using the following jquery code to get it worked but it's not working as expected

    var check_box =  fw.component_helper.get_table_column_editor(fw.form_constants.CHECK_BOX);//header checkbox 
$("check_box").attr('checked',true);

Note: fw is my own defined framework

Please suggest what's wrong with this approach

use prop instead of attr. What is "$('check_box')". Define weather it is class or id. you selector is wrong here I thing this could be problem.

$(".check_box").prop('checked',true);

or

$("#check_box").prop('checked',true);

or

$("input[type='checkbox']").prop('checked',true);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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