<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Call Me Goon &#187; HTML</title>
	<atom:link href="http://callmegoon.com/tag/html/feed/" rel="self" type="application/rss+xml" />
	<link>http://callmegoon.com</link>
	<description></description>
	<lastBuildDate>Wed, 12 Oct 2011 22:50:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Create a fun, clean, easy to use FAQ list with jQuery!</title>
		<link>http://callmegoon.com/create-a-fun-clean-easy-to-use-faq-list/</link>
		<comments>http://callmegoon.com/create-a-fun-clean-easy-to-use-faq-list/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 04:01:14 +0000</pubDate>
		<dc:creator>Goon</dc:creator>
				<category><![CDATA[HTML/CSS]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://callmegoon.com/?p=906</guid>
		<description><![CDATA[This tutorial demonstrates how to create a jQuery FAQ list that is both easy to use and easy to create. View a real life example. FAQ pages are often a long list of questions followed by answers, or a list of questions that anchor link to an answer further down the page. Neither one creates [...]]]></description>
			<content:encoded><![CDATA[<img class="alignleft size-full wp-image-908" title="jQuery FAQ List" src="http://callmegoon.com/wp-content/uploads/2009/09/Featured-List.jpg" alt="jQuery FAQ List" width="143" height="125" />
<p>This tutorial demonstrates how to create a jQuery FAQ list that is both easy to use and easy to create.  <a class="newwindow" href="http://www.gatewaygi.com/faqs">View a real life example.</a></p>
<p>FAQ pages are often a long list of questions followed by answers, or a list of questions that anchor link to an answer further down the page.  Neither one creates a very usable way for users to easily find the information they are looking for.</p>
<p>The following script fixes all of that by creating a clean page that puts the user in control of what information to display.</p>

<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0' width='560' height='345'><param name='movie' value='http://screenr.com/Content/assets/screenr_0817090731.swf' ></param><param name='flashvars' value='i=15231' ></param><param name='allowFullScreen' value='true' ></param><embed src='http://screenr.com/Content/assets/screenr_0817090731.swf' flashvars='i=15231' allowFullScreen='true' width='560' height='345' pluginspage='http://www.macromedia.com/go/getflashplayer' ></embed></object>

<h3>The HTML</h3>
<p>First we wrap everything in a wrapper div and give it a class name.  Within this div is an h5.  This h5 is actually our question.  It doesn't have to be an h5, but if you use a different element, you will have to edit the jQuery accordingly to target the element you have chosen to use.  Next, we have a div with a class of answer.  We will be targeting this div in order for the user to be able to show and hide the answer.  Within this div is a paragraph tag with some filler lorem ipsum text.</p>
<p>That is all you need to create the HTML for one question, however, to get the full effect, you will want to copy and past this code a few times so that  you have a few questions.</p>
<pre class="brush: xml; title: ; notranslate">
&amp;amp;lt;div class=&amp;amp;quot;FAQWrap&amp;amp;quot;&amp;amp;gt;
  &amp;amp;lt;h5&amp;amp;gt;This is my question?&amp;amp;lt;/h5&amp;amp;gt;
  &amp;amp;lt;div class=&amp;amp;quot;answer&amp;amp;quot;&amp;amp;gt;
    &amp;amp;lt;p&amp;amp;gt;Notare quam littera gothica quam, nunc putamus parum claram anteposuerit litterarum. Et quinta decima eodem modo typi qui nunc. Per seacula quarta decima nobis videntur parum clari: fiant sollemnes in.  Equitur mutationem consuetudium lectorum mirum est formas humanitatis.&amp;amp;lt;/p&amp;amp;gt;
    &amp;amp;lt;/div&amp;amp;gt;
  &amp;amp;lt;/div&amp;amp;gt;
</pre>

<h3>The CSS</h3>
<p>The styles are essentially unimportant.  You can styles the layout any way you want, but I will give some insight into some of the styles I often choose when creating an FAQ page.</p>
<p>The first thing to note is that I give my h5 a cursor: pointer style.  This creates the hand pointer when the user hovers on the question.  That gives the user a clear indication that something will happen if they click on this question.</p>
<p>You will also see that I have different background images for the h5 depending on whether it has a class of inactive or active.  We will change this class with jQuery when the user clicks the question and the class, along with the background image arrow, will toggle, again creating visual interactivity between the user and the page.</p>
<pre class="brush: css; title: ; notranslate">
#content {width: 960px; margin: 0 auto;}
.FAQWrap h5 {color: #555; margin: 10px 0 0 0; padding: 0 0 0 20px; font-size: 14px; font-weight: normal; cursor: pointer;}
.FAQWrap h5.inactive {background: url(../images/bg-faq-inactive.png) no-repeat 0 3px;}
.FAQWrap h5.active {background: url(../images/bg-faq-active.png) no-repeat 0 3px;}
.FAQWrap .answer {background: #EEE; margin: 10px 10px 20px 30px; padding: 10px;}
</pre>

<h3>The jQuery</h3>
<p>And finally, the most important part, the jQuery.  Remember of course to first link to the jQuery framework.</p>
<p>The first thing we do is hide all answer divs when the page loads.  That creates the nice clean layout we are looking for and puts the control in the hands of the user as which information they want displayed on the page.</p>
<p>Next, we target all h5's within the FAQWrap div and assign a class of inactive.  This, along with our CSS on the h5, will create a background image of an arrow pointing to the right, denoting that the answer is hidden, but can be displayed if you click the question.</p>
<p>The next thing we want to do is run a function when we click on an h5 within FAQWrap.  The first thing we do is use this toggleClass method to switch the class of the actual h5 we clicked.  toggleClass simply toggles the class name on the targeted element.  If it has a class of 'inactive', it will switch the class to 'active', and if it is 'active', it will switch the class to 'inactive'.   So, hopefully you are now beginning to see that each time we click on an h5, we are switching the class name between 'inactive' and 'active', and that, in combination with our CSS, is what is changing our background image arrow on the h5.</p>
<p>The last thing we do, which is most important, is slideToggle the answer div.  The way we do that is first find the parent of 'this' (the h5 we are clicking on), then we are finding the div with a class of answer within that parent element, and slideToggling it.  This means that if the answer is showing, it will slideUp and and be hidden, and if it is hidden, it will slideDown and show.</p>
<pre class="brush: jscript; title: ; notranslate">
$(function() {
      $('.answer').hide();
      $('.FAQWrap h5').addClass('inactive');
      $('.FAQWrap h5').click(function() {
        $(this).toggleClass('active');
        $(this).toggleClass('inactive');
        $(this).parent().find('.answer').slideToggle();        
      });
    });
</pre>

<h3>The Demo</h3>
<p>And so when you put all of that together, you get a nice, clean, easy to use FAQ page that any user will enjoy using!</p>
<style type="text/css" media="screen">
.FAQWrap h5 {color: #555; margin: 10px 0 0 0; padding: 0 0 0 20px; font-size: 14px; font-weight: normal; cursor: pointer;}
.FAQWrap h5.inactive {background: url(/wp-content/themes/simplebeginnings/images/bg-faq-inactive.png) no-repeat 0 3px;}
.FAQWrap h5.active {background: url(/wp-content/themes/simplebeginnings/images/bg-faq-active.png) no-repeat 0 3px;}
.FAQWrap .answer {background: #EEE; margin: 10px 10px 20px 30px; padding: 10px;}
</style>
<script type="text/javascript" charset="utf-8">
    $(function() {
      $('.answer').hide();
      $('.FAQWrap h5').addClass('inactive');
      $('.FAQWrap h5').click(function() {
        $(this).toggleClass('active');
        $(this).toggleClass('inactive');
        $(this).parent().find('.answer').slideToggle();        
      });
    });
  </script>
<div class="FAQWrap">
      <h5>This is my question?</h5>
      <div class="answer">
        <p>Notare quam littera gothica quam, nunc putamus parum claram anteposuerit litterarum. Et quinta decima eodem modo typi qui nunc. Per seacula quarta decima nobis videntur parum clari: fiant sollemnes in. Sequitur mutationem consuetudium lectorum mirum est formas humanitatis.</p>
      </div>
    </div>
    <div class="FAQWrap">
      <h5>This is my question?</h5>
      <div class="answer">
        <p>Notare quam littera gothica quam, nunc putamus parum claram anteposuerit litterarum. Et quinta decima eodem modo typi qui nunc. Per seacula quarta decima nobis videntur parum clari: fiant sollemnes in. Sequitur mutationem consuetudium lectorum mirum est formas humanitatis.</p>
      </div>
    </div>
    <div class="FAQWrap">
      <h5>This is my question?</h5>
      <div class="answer">
        <p>Notare quam littera gothica quam, nunc putamus parum claram anteposuerit litterarum. Et quinta decima eodem modo typi qui nunc. Per seacula quarta decima nobis videntur parum clari: fiant sollemnes in. Sequitur mutationem consuetudium lectorum mirum est formas humanitatis.</p>
      </div>
    </div>

<p class="source"><a href="/sourcefiles/FAQExample.zip">Download the source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://callmegoon.com/create-a-fun-clean-easy-to-use-faq-list/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

