Jquery select all checkboxes inside tab

I have several tabs. Each tab has several nested elements that contain check box input elements. I need to be able to select all / none of the checkboxes on the selected tab. I was hoping this would work:

$("#tabs").tabs().data("selected.tabs").('input[@type=checkbox]').attr('checked', 'checked');

But this is not so. I thought I could get an element of the selected tab and then iterate over all the children of this element that are looking for checkboxes. However, it’s hard for me to figure out how to get an element (not an index) of the selected element. If anyone knows how, please let me know.

EDIT:

I assumed that everyone knows the structure of jquery tabs.
The tabs are in the UL above and separated from the DIV, which actually contain the contents and checkboxes for the tab.

<ul><li>tab0</li>... </ul><div id="tab0"> checkboxes here </div>

I need to find the selected tab, and then find the div corresponding to the tab. I think the div is called a panel property, but I can't figure out how to access this panel property as soon as I find the tab. See jquery tabs

+3
source share
2 answers

Try:

$("#tabs").tabs().data("selected.tabs").find(':checkbox').attr('checked', 'checked');
+2
source

Typically, the “selected” tab has a specific class name to identify it as the selected tab. You can easily identify this class name through firebug or equivalent. Assuming the class name is "selected", we could do the following:

$("#tabs .selected :checkbox:checked");
+2
source

Source: https://habr.com/ru/post/1727564/


All Articles