Styling the text within an element

We are often faced with a reason to style text on-the-fly using client-side code. MooTools makes that quite elementary with concepts found prominent in this very recipe!

Getting ready

Prepare to make the text in our SPAN stand out: by making it bold.

How to do it...

It is possible to set the styles of any text element quickly and easily.

<script type="text/javascript" src="mootools-1.3.0.js"></script> </head> <body> <form action="" method="get"> <input id="go_bold" type="button" value="Bold Oscar"/> <input id="go_div" type="button" value="Set Oscar Apart"/> </form> <br/> <div>Every great man nowadays has his disciples, and it is always Judas who writes the biography. <span id="quote_author">Oscar Wilde</span></div> ...

Get MooTools 1.3 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.