Forum:Button that will apply css style

would it be possible to write a javascript routine (placed in the site-wide javascript page) that would allow one to click a button and apply a given style to that page?

One could have multiple buttons on the page and each would cause certain elements to take on a given color or not be displayed at all.

Something similar to the collapsible tables button. The code for this button looks like

Granpa 04:31, December 24, 2011 (UTC)


 * I don't see why not. Maybe you could have something like:

turn blue box green
 * ...of course, I don't know if MediaWiki would actually let that work. 04:44, December 24, 2011 (UTC)

Lets see

turn blue box green

span with id=blueBox

div with id=blueBox

Granpa 07:02, December 24, 2011 (UTC)


 * Nope, looks like MediaWiki removes the onclick. Of course, you could always use verbatim tags. 07:08, December 24, 2011 (UTC)


 * Yes! It works. Thats fabulous. Thank you. Granpa 07:19, December 24, 2011 (UTC)


 * But it only turns the first element with id=blueBox green. Granpa 07:21, December 24, 2011 (UTC)


 * The code for changing attributes for multiple elements is a little bit harder. Maybe jQuery? I'm new at this, but I think the code would be:

$(".blueBox").css("background-color","green"); 07:54, December 24, 2011 (UTC)


 * I tried that and it had no effect.
 * I was thinking more along the lines of adding a javascript routine to the site-wide javascript page and calling it from the button like it does for collapsible tables.




 * Granpa 08:02, December 24, 2011 (UTC)

heres a routine I got a long time ago that redirects all new links to wikipedia:

Granpa 08:14, December 24, 2011 (UTC)


 * Yes, and that would work perfectly fine, but the part I'm worried about is that HTML links are against the rules of WikiMarkup (which is why my original reply was a div with an onclick instead). I can't see a way to make that work with the normal link markup. I would doubt  does anything. But you could do that with onclick too. It would just be  . 08:21, December 24, 2011 (UTC)