Select Row or Column of checkboxes from matrix using javascript
As the title states I was wondering how i could perform the task of selecting a whole row/column of checkboxes using javascript as i have already done it with a foreach but that tak开发者_JS百科es 3 seconds i wish that i can make this less.
1 2 3 4 5 select start end
1 Button
2
3
4
5
select
Im not sure how to depict it exactly i hope that this can better explain.
You could use css classes to designate the rows and columns for each checkbox, and then use jQuery to get the row or column of interest, like in this fiddle.
In the example, $('.r2')
gets all checkboxes with the class 'r2' (ie., in row 2) ... change it to $('.c3')
to get all in column 3.
Here is an example of creating a button to check a row or column.
UPDATE: Here is a more dynamic example
check out jQuery's .each function it would make that task piece of cake :)
Let me know if you need assistnace with it.
精彩评论