Java Reference
In-Depth Information
element.className = swim.className + " " +
newClass;
} else {
element.className = newClass;
}
return element.getAttribute("class");
}
Let's test this out on the
swim
element, which already has a class of '
swim
':
addClass(swim,"sport");
<< "swim sport"
Let's check that it works for the
run
element, which was without a
class
attribute:
addClass(run,"run");
<< "run"
Now the element has a class of '
run
'.
