JS getelementsbyclassname

getElementsByClassName() method grabs all items with the class name into an array.

<STYLE type="text/css">
.n td{border:1px solid #9FA4FF;}
.r td{border:2px solid red;}
.s td{border:1px solid #9FA4FF;}
<script language="javascript">
function change()
var arr=document.getElementsByClassName("n");
for (var i=0;i<arr.length;i++)
<input name="change" type=button onclick="change()" value="Change" style="font-size:18px">
<table border=0>
<tr class="n"><td>Bangalore, India</td></tr>
<tr class="s"><td>New York, USA</td></tr>
<tr class="n"><td>Mombay, India</td></tr>
<tr class="s"><td>San Francisco, USA</td></tr>
<tr class="n"><td>New Delhi, India</td></tr>
<tr class="s"><td>Washington DC, USA</td></tr>

Bangalore, India
New York, USA
Mombay, India
San Francisco, USA
New Delhi, India
Washington DC, USA

endmemo.com © 2024  | Terms of Use | Privacy | Home