The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

emike (1) [Avatar] Offline
#1
I need some help with the Scriptaculous HighlightEffect function to highlight one entire sentence of a paragraph. The onclick action needs to come from outside the paragraph. In the example below, the third sentence will be highlighted in red after clicking on the "Click here to check your answer," sentence that follows the paragraph.

For example:

November and December are wonderful months for gardening in the south. While residents of northern states are more concerned with preparations for winter, gardeners in southern states can enjoy natural circumstances that enhance their efforts. Football enthusiasts in November and December can enjoy the sport throughout the country. Temperatures in the south are warm enough to grow abundant amounts of flowers and vegetables. Plants and gardeners are relatively free from the pesky bug populations that present problems during the summer. If you enjoy gardening, you'll find November and December good months in the south.

Click here to check your answer.


Any ideas on how to do this? I'm new to script.aculo.us if it's not obvious. Just need a little help.

Thanks,
Mike
jpschroeder (2) [Avatar] Offline
#2
Re: Need help with HighlightEffect function
If you have prototype included in your file, you can simply assign the portion of script you want to highlight an id. for example:




...gardening in the south. <span id='highlight_this'> While residents of northern
states are more concerned with preparations for winter, gardeners in southern states can
enjoy natural circumstances that enhance their efforts.</span> Football enthusiasts....





then your onclick could look like this (this can be placed anywhere in the same document):

<a href="#" onclick="new Effect.Highlight($('highlight_this')); return false;"> Click here to check your answer.</a>


That should do it! let me know if it works