jquery select all checkboxes inside a tab
I have several tabs. Each tab has several nested elements that contain checkbox input elements. I need to be able to select all / none of the the checkboxes within the selected tab. I was hoping this would work:
$("#tabs").tabs().data("selected.tabs").('input[@type=checkbox]').attr('checked', 'checked');
But it doesn't. I was thinking that I could get the element of the selected tab and then iterate all the children of that element looking for checkboxes. However, I am having trouble figuring out how to get the element (not index) of the selected element. If someone knows how, please let me know.
EDIT:
I assumed everyone knew the structure of the jquery tabs.
The tabs are in a UL above and separate from the DIVs that actually contain the content and checkboxes for the tab.<ul><li>tab0</li>... </ul><div id="tab0"> checkboxes here </div>
I need to find th开发者_运维百科e selected tab and then find the div that corresponds to the tab. I think the div is called the panel property but I can't figure out how to access that panel property once I find the tab. Please see jquery tabs
Try:
$("#tabs").tabs().data("selected.tabs").find(':checkbox').attr('checked', 'checked');
Typically, a "selected" tab comes with a specific classname to identify it as the selected tab. You can easily identify this classname via firebug, or an equivalent. Assuming that classname is 'selected,' we could do the following:
$("#tabs .selected :checkbox:checked");
精彩评论