View Full Version : Styling buttons

Sep 8th, 2007, 10:22 PM
I'm styling forum inputs and they all look lovely but I dont want my submit buttons styled the same way.
But I also don't want to go through every page in the site looking for buttons and assigning a class to them

So I'm thinking of doing something along the lines of this:

onload = function()
inputs = document.getElementsByTagName('input');
for(i=0 i<inputs.length; i++)
inputs[i].className = 'buttonStyle';

But I was wondering if there was a better/simplier/more elegant solution?

Sep 8th, 2007, 10:54 PM
when css3 comes along you'd be able to put something along the lines of:

input[type="submit"] {
/*whatever styles*/

but that's a long way off.

Firefox3 will let you select using xpath:

var submits = document.getElementsByXPath('//input[@type="submit"]');

can't see that making it into IE anytime soon though, so what you've got is about as good as it getss.

If any of the other features would be of benefit, then the prototype.js library would let you do:


others have similar selector functionality.

Sep 8th, 2007, 10:59 PM
Guess I'll go with that then, since I'm already using prototype. I wish these things came with better documentation.