Codice PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
title>Untitled Document</title>
<
meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<
script language="JavaScript" type="text/JavaScript">
function 
lolloso()
{
    var 
mioArray document.getElementsByTagName("div");
    var 
lun mioArray.length//individuo la lunghezza dell'array 
    
for (n=0;n<lun;n++) 
    { 
        if (
mioArray[n].className=="prova"
        {
            
mioArray[n].className="prova2";
        }
    }
}

</script>

<style type="text/css">
.prova {
    background-color: red;
    width: 200px;
    height: 50px;
    color: blue;
    text-align: center;
    overflow: none;

.prova2 {
    background-color: blue;
    width: 200px;
    height: 50px;
    color: red;
    text-align: center;
    overflow:auto;

</style>

</head>

<body>
<div class="prova">
antoniio ciao come stai?
rgrgergregegaegaega
antoniio ciao come stai?
rgrgergregegaegaega
</div>
<div class="prova">
antoniio ciao come stai?
rgrgergregegaegaega
antoniio ciao come stai?
rgrgergregegaegaega
</div>
<form>
<input type="button" name="anto" value="prova" onClick="lolloso()">
</form> 


</body>
</html>