Project Avant Facebook Page Project Avant Twitter Page

tutorial #1: Spoiler Revealer

The third and final demo in this tutorial is the Spoiler Revealer. You will see how to create spoiler revealer buttons by exclusively using jQuery to insert them in the webpage. You can insert elements to or remove elements from your webpage through jQuery.

Below is a demonstration of spoiler revealer. Click on each button to reveal movie ending.

the usual suspects (1995) - Kevin Spacey was actually Keyser Soze.

the sixth sense (1999) - Bruce Willis is a ghost

Mulholland Drive (2001) - Um.....stuff happened, so....yeah

The How-To




<h2>Movie Spoilers!</h2>

<p>the usual suspects (1995) - 
<span class="ending">Kevin Spacey was actually Keyser Soze.</span>

<p>the sixth sense (1999) - 
<span class="ending">Bruce Willis is a ghost</span>

<p>Mulholland Drive  (2001) - 
<span class="ending">Um.....stuff happened, so....yeah</span>




section {

section p {
	margin:20px auto;


// This is needed to make the document ready and functional.
//This method will hide elements with a designated attribute. 
  $('<input type="button" class="revealer" value="Are Sure? This is Your Last Chance "/>').insertBefore('.ending');
//This line will insert new elements to the webpage, like the button here.
//The button will be place before the designated element by using the 'insertBefore.()' method.
//This will trigger the event, when the button is click on. 
//Once the button is click on, '$(this).hide()' will remove the element.
//Will fade in the original element.  
});//Close it out.