1

Possible Duplicate:
Can getElementsByClassName change style?

I am trying to "fix" the "new" YouTube using Greasemonkey, I've been getting things to work as they should when it's with ID's, however I have been unable to modify anything with a class, it appears I am unable to select it or whatever anyways.

I have been trying to use:

document.getElementsByClassName("video-extras-sparkbar-likes").style.height='10px';

However it isn't working. :\

I'm not very familiar with Greasemonkey and what not, so would there be a reason why though my browser supports this, Greasemonkey may not?

4

1 回答 1

3

You might need to loop through the results, like this:

var divs = document.getElementsByClassName('video-extras-sparkbar-likes');
for(var i=0; i < divs.length; i++) { 
  divs[i].style.height = '10px';
}
于 2012-12-09T06:35:41.840 回答