I use the following function to expand the footer border for a website I'm creating:

<script type="text/javascript">
var x=5; <!--original height-->
function expand() {

document.getElementById("footer").style.height=x+'em'; <!--Gets the height from css.css in the div "move"-->
if(x>10) { <!--Desired height after expansion-->
x++; <!--desired height isn't yet reached, keep expanding-->
t=setTimeout('expand()',0); <!--Speed of expansion-->

where I get the element by id however I've changed the footer to a div class now so it doesn't read this properly and the border doesn't expand. How can I work around this problem?

Edited by asif49: n/a

6 Years
Discussion Span
Last Post by asif49

I'm not too sure^^ Would that be a better option? And how would it be done?


You could use document.getElementsByClassName(nameOfClassName) on Firefox. However, I doubt that you want your web page to work only on Firefox. What you can do is to go through each elements by yourself.

function myGetElementsByClassName(tagname, classname) {
  var elems = document.getElementsByTagName(tagname)
  var results = new Array()
  if (elems.length>0 && classname) {
    for (var i=0; i<elems.length; i++) {
      if (elems[i].className==classname) {
  return results

// Assume that you are looking for all div elements having "footer" as class name
// Then you call it as ...
var myFooters = myGetElementsByClassName("div", "footer")

PS: As others said above, why are you using "setTimeout()" with 0 time??? If you are going to call it, why not simply call the function instead of using "setTimeout()"?

Edited by Taywin: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.