---
title: "js遍历页面中所有的checkbox，全选checkbox"
author: "starnc"
date: "2009-03-03T19:29:00Z"
tags: []
slug: "js-checkbox-checkbox"
draft: false
lastmod: "2009-04-03T08:47:57Z"
id: 360416
url: "https://starnc.iteye.com/blog/360416"
---

function selectAll()  
        {  
            var arrAll=document.all;  
            for(var i=0;i&lt;arrAll.length;i++)  
            {  
                if(arrAll\[i].type=='checkbox')    
                {  
                    document.getElementById(arrAll\[i].id).checked=document.getElementById("chkAll").checked;  
                }  
            }  
        }