简体   繁体   中英

How to get selected “CheckBoxes” from tree view using javascript?

I am using asp TreeView control. I want to get selected "checboxes" values at client side. How do I get selected values from TreeView?

Suppose your treeview has id treeviewid

$('#treeviewid input[type=checkbox]:checked').each(function(){
   alert($(this).val());    
});

I think you should use clientId

$('#<%=MyTreeView.ClientID%>').find(':checkbox:checked').each(function(){
   console.log($(this).val());    
});

I've used the following code to determine all the checked checkboxes:

$("input:checkbox").each(function () {
    if ($(this).is(':checked')) {
        //do something
    }
}

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