Question : JavaScript: Get all checkboxes inside div

My code gets all checkboxes but I only want the checkboxes inside <div id="special">
1:
2:
3:
4:
5:
6:
var inputs = document.getElementsByTagName("input"); 
   for (var i = 0; i < inputs.length; i++) {
     if (inputs[i].type == "checkbox") {
     /// Do something
     }
   }


 In the example below I want the first two checkboxes but not the last two.
1:
2:
3:
4:
5:
6:
7:
8:
9:
<div id="special">
<input type="checkbox" name="a" value="1" />
<input type="checkbox" name="b" value="2" />
</div>

<div id="other">
<input type="checkbox" name="c" value="3" />
<input type="checkbox" name="d" value="4" />
</div>

Answer : JavaScript: Get all checkboxes inside div

to be more specific way..
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
<script>

window.onload=function()
{

var div = document.getElementsByTagName("div"); 


for(j=0;j<div.length;j++)
{

if(div[j].id == 'special')
{
var special = document.getElementById(div[j].id).childNodes; 



 for (var j = 0; j < special.length; j++)
 {


		 if(special[j].nodeName == 'INPUT')
		 {
		   special[j].checked=true;
		 }

 }

 }

 }

 }
 

 

</script>
Random Solutions  
 
programming4us programming4us