Forum Moderators: open
I have a style rule such as
.humo {visibility: visible}
and then, when a specific event takes place, the following Javascript is executed:
var mysheet=document.styleSheets[0]
var humorule=mysheet.cssRules? mysheet.cssRules[0]: mysheet.rules[0]
//Access the first rule of the first stylesheet
//one of the above works in IE, the other in Mozilla family
if(inp<1) humorule.style.visibility="hidden"
else humorule.style.visibility="visible"
The HTML:
<input type="checkbox" onClick="recalculate();" accesskey="i">Always shown
<input type="checkbox" onClick="pickups(pickup.value)" class="humo">Sometimes shown
So there are a lot of checkboxes, some of which need to be disabled or invisible when certain conditions are met.
I suppose my question is: of the two properties
mysheet.cssRules[0]
mysheet.rules[0]
Is there any consensus as to which is best? Or, in other words, which of these (if any) are official W3C, and which are supported in Safari and/or Opera 9? (I currently don't have access to either, and the web comparisons are hazy on this). I'd prefer not to get into a massive branching fest, so I'm going to limit myself to two alternatives
Or, is there any better way of doing this without looping through all the checkboxes individually?
I guess that would be the neatest way. I'm not sure how you would do it if you wanted to change several classnames at once without a loop...