<?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>Ryan Stemkoski &#187; JavaScript</title>
	<atom:link href="http://www.stemkoski.com/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.stemkoski.com</link>
	<description>Web design tips &#38; tricks plus anything else I want to talk about...</description>
	<lastBuildDate>Sat, 07 Jan 2012 18:34:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How to Make a Cross Domain AJAX Request with jQuery</title>
		<link>http://www.stemkoski.com/how-to-make-a-cross-domain-ajax-request-with-jquery/</link>
		<comments>http://www.stemkoski.com/how-to-make-a-cross-domain-ajax-request-with-jquery/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 22:04:37 +0000</pubDate>
		<dc:creator>Ryan Stemkoski</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Cross Domain]]></category>

		<guid isPermaLink="false">http://www.stemkoski.com/?p=1522</guid>
		<description><![CDATA[I am currently working on a project that required me to make a cross-domain AJAX request using jQuery. This is a function that is disabled by default because of security implications, however, there is occasionally a need for this type of request. In this case, I need to load content from a remote URL or [...]


Related posts:<ol><li><a href='http://www.stemkoski.com/how-to-get-fixed-header-and-footer-toolbars-in-jquery-mobile-1-0/' rel='bookmark' title='Permanent Link: How to get Fixed Header and Footer Toolbars in jQuery Mobile 1.0'>How to get Fixed Header and Footer Toolbars in jQuery Mobile 1.0</a> <small>At Zipline Interactive, we have been doing mobile websites for...</small></li>
<li><a href='http://www.stemkoski.com/accurate-cross-browser-testing-with-browserstack-com/' rel='bookmark' title='Permanent Link: Accurate Cross Browser Testing With BrowserStack.com'>Accurate Cross Browser Testing With BrowserStack.com</a> <small>The worst job for any web developer is testing your...</small></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I am currently working on a project that required me to make a cross-domain AJAX request using jQuery.  This is a function that is disabled by default because of security implications, however, there is occasionally a need for this type of request.  In this case, I need to load content from a remote URL or website similar to how you would load content using jQuery&#8217;s .load() function or using PHP&#8217;s file_get_contents() function.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">/********************************************************************************
FUNCTION FOR CROSS DOMAIN AJAX REQUEST USING JQUERY 1.5+
********************************************************************************/</span>  
<span style="color: #003366; font-weight: bold;">function</span> loadContents<span style="color: #009900;">&#40;</span>url<span style="color: #339933;">,</span> callback<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>  
&nbsp;
    <span style="color: #006600; font-style: italic;">//CONFIRM A URL WAS PROVIDED  </span>
    <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>url<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>  
&nbsp;
	    <span style="color: #006600; font-style: italic;">//SET URL FOR YAHOO YQL QUERY</span>
	    <span style="color: #003366; font-weight: bold;">var</span> yql <span style="color: #339933;">=</span> <span style="color: #3366CC;">'http://query.yahooapis.com/v1/public/yql?q='</span> <span style="color: #339933;">+</span> encodeURIComponent<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'select * from html where url=&quot;'</span> <span style="color: #339933;">+</span> url <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot;'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&amp;format=xml&amp;callback=?'</span><span style="color: #339933;">;</span>  
&nbsp;
		<span style="color: #006600; font-style: italic;">//MAKE YAHOO YQL QUERY  </span>
	   	$.<span style="color: #660066;">getJSON</span><span style="color: #009900;">&#40;</span>yql<span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
			<span style="color: #006600; font-style: italic;">//BUILD CALLBACK FUNCTION</span>
			<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> callback <span style="color: #339933;">===</span> <span style="color: #3366CC;">'function'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>  
			    callback<span style="color: #009900;">&#40;</span>data.<span style="color: #660066;">results</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
			<span style="color: #009900;">&#125;</span>  
&nbsp;
		<span style="color: #006600; font-style: italic;">//WRITES ERROR TO LOG	</span>
	    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">error</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>jqXHR<span style="color: #339933;">,</span> textStatus<span style="color: #339933;">,</span> errorThrown<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
	    	console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>errorThrown<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
	    <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  	<span style="color: #006600; font-style: italic;">//LOG ERROR IF NO URL WAS PASSED TO THE SCRIPT</span>
  	<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
  		 console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'No site was passed to the script.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
  	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span> 
&nbsp;
<span style="color: #006600; font-style: italic;">/********************************************************************************
SAMPLE USAGE
********************************************************************************/</span> 
loadContents<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'http://www.ziplineinteractive.com/frame/'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>results<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>  
   $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#wrapper'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span>results<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>I have tested this function in IE, Firefox, Chrome, and Safari and it should allow you to make cross-domain AJAX requests in jQuery 1.3, 1.4, 1.5, 1.6, 1.7, and from what I been able to find online it should also be supported in 1.8, although, 1.8 is not available at this time.</p>
<p>Let me know how this works in your application.</p>


<p>Related posts:<ol><li><a href='http://www.stemkoski.com/how-to-get-fixed-header-and-footer-toolbars-in-jquery-mobile-1-0/' rel='bookmark' title='Permanent Link: How to get Fixed Header and Footer Toolbars in jQuery Mobile 1.0'>How to get Fixed Header and Footer Toolbars in jQuery Mobile 1.0</a> <small>At Zipline Interactive, we have been doing mobile websites for...</small></li>
<li><a href='http://www.stemkoski.com/accurate-cross-browser-testing-with-browserstack-com/' rel='bookmark' title='Permanent Link: Accurate Cross Browser Testing With BrowserStack.com'>Accurate Cross Browser Testing With BrowserStack.com</a> <small>The worst job for any web developer is testing your...</small></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.stemkoski.com/how-to-make-a-cross-domain-ajax-request-with-jquery/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How to get Fixed Header and Footer Toolbars in jQuery Mobile 1.0</title>
		<link>http://www.stemkoski.com/how-to-get-fixed-header-and-footer-toolbars-in-jquery-mobile-1-0/</link>
		<comments>http://www.stemkoski.com/how-to-get-fixed-header-and-footer-toolbars-in-jquery-mobile-1-0/#comments</comments>
		<pubDate>Wed, 23 Nov 2011 13:23:09 +0000</pubDate>
		<dc:creator>Ryan Stemkoski</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Mobile Apps]]></category>
		<category><![CDATA[Mobile Websites]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[jQuery Mobile]]></category>

		<guid isPermaLink="false">http://www.stemkoski.com/?p=1457</guid>
		<description><![CDATA[At Zipline Interactive, we have been doing mobile websites for a number of years. When we originally started building them, most customers were satisfied with a very simple website but as the mobile market has grown and more and more users have smartphones, many customers expect their mobile website to function much like a mobile [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.stemkoski.com/wp-content/uploads/2011/11/Screen-Shot-2011-11-23-at-5.28.58-AM.png"><img src="http://www.stemkoski.com/wp-content/uploads/2011/11/Screen-Shot-2011-11-23-at-5.28.58-AM.png" alt="" title="Screen Shot 2011-11-23 at 5.28.58 AM" width="266" height="288" class="alignright size-full wp-image-1461" style="margin-left: 10px;" /></a>At Zipline Interactive, we have been doing mobile websites for a number of years. When we originally started building them, most customers were satisfied with a very simple website but as the mobile market has grown and more and more users have smartphones, many customers expect their mobile website to function much like a mobile app.   In addition, tools like PhoneGap and Appcelerator have provided web developers with the ability to create cross platform mobile applications using HTML5 and Javascript.  The key with developing mobile websites or applications using web technologies, is mimicking the devices user interface and animations for a consisten user experiene.  There are a number of great Javascript frameworks designed to assist with this task.  As I have worked with and tested these platforms my clear favorite is jQuery Mobile. It has a great deal of momentum and support, plus I am already a heavy jQuery user so the learning curve is very low. </p>
<p>One of the the biggest problems facing mobile web developers is the ability to create fixed headers and footers on mobile websites and HTML5 powered mobile applications.  The problem is caused by the lack of standard support for the CSS properties position:fixed and overflow.  Originally, these were not supported because they interfered with the touch interactions of the phone operating system but as of iOS5 and Android 2.1 there is rudimentary support for position:fixed. If you would like to see the level of support for these properties in the various mobile browsers, there is a handy chart available here: http://e.com/css-fixed. </p>
<p>The good news is that default support is on the way.  The bad news is that it is not here yet.  Regardless of the mobile platform you are targeting, there will be a large percentage of users that are unable to use your interface properly if you rely on position:fixed or overflow.  In jQuery Mobile, there is a default solution.  They have built in toolbars that mimic a fixed header and footer by fading out and repositioning as the screen moves.  While this is an improvement, it is still not a solution for a developer wanting a native app look and feel.</p>
<h2>So what is the solution?</h2>
<p>After a great deal of research and testing I found there were two primary solutions for this problem being used by fans of the jQuery Mobile platform.  They both use Javascript to modify the elements and mimic the scrolling functionality of a native application. </p>
<h3>Solution 1: iScroll jQuery Mobile Plugin</h3>
<p>URL: https://github.com/yappo/javascript-jquery.mobile.iscroll<br />
This jQuery Mobile plugin is a wrapper for the iScroll Javascript function. (http://cubiq.org/iscroll-4)  This plugin is made up of a single file that drops in to your HTML and then is initiated by adding &#8216;data-iscroll=&#8221;scroller&#8221;&#8216; to the element you want to scroll.  This plugin was very easy to setup and worked, however, the animation was slow on android applications and when loading websites on the iPhone I had a persistent space at the bottom of the page that I could not remove.  I believe it was caused during loading by the default iPhone toolbars but I am uncertain. I searched online and wasn&#8217;t able to find a suitable solution.  Many users have reported this solution worked well for them and several indicated they were using it successfully with the PhoneGap platform.</p>
<h3>Solution 2: Scrollivew</h3>
<p>URL: http://jquerymobile.com/test/experiments/scrollview/<br />
Download URL: https://github.com/jquery/jquery-mobile/tree/master/experiments/scrollview<br />
This jQuery Mobile plugin is actually sponsored by jQuery and is currently listed under their experiments section on the jQuery Mobile website.  It was a bit harder to get running.  It required 4 files, 3 Javascript files and 1 CSS file, although, I was able to lump them together into existing application files to minimize HTTP requests.  This solution worked very well for my application. After installing the scripts I simply added  data-scroll=&#8221;true&#8221; to the element I wanted scrollable and the plugin took care of the rest.  One important thing to note about this solution, is that in addition to simple fixed toolbars, this plugin also allows scrolling of on page elements left or right and can also handle scrollable lists with inline headers.</p>
<h2>My Conclusion:</h2>
<p>After extensively testing both of the primary scrolling options for jQuery Mobile I feel like the jQuery Mobile Scrollview is the best solution.  It was very easy to install and configure, offered great support on iPhone and Android devices, and has more options and configurations available to customize your application.  In addition, it may at some point be integrated into jQuery mobile as default functionality to serve as a bridge until position:fixed and overflow are full supported by the majority of active smartphones.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.stemkoski.com/how-to-get-fixed-header-and-footer-toolbars-in-jquery-mobile-1-0/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Easily Find the Latest Versions of Javascript Libraries at Google Code</title>
		<link>http://www.stemkoski.com/easily-find-the-latest-versions-of-javascript-libraries-at-google-code/</link>
		<comments>http://www.stemkoski.com/easily-find-the-latest-versions-of-javascript-libraries-at-google-code/#comments</comments>
		<pubDate>Tue, 04 May 2010 18:21:17 +0000</pubDate>
		<dc:creator>Ryan Stemkoski</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[jQuery UI]]></category>

		<guid isPermaLink="false">http://www.stemkoski.com/?p=1408</guid>
		<description><![CDATA[A couple days ago Dustin brought a great site to my attention. It is called ScriptSrc.net and is located at: http://scriptsrc.net/. Using this site, a developer can easily locate and copy the latest stable version of their favorite library. This can be a real time saver in searching out the various library links. It would [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>A couple days ago Dustin brought a great site to my attention.  It is called ScriptSrc.net and is located at: <a href="http://scriptsrc.net/">http://scriptsrc.net/</a>. </p>
<p>Using this site, a developer can easily locate and copy the latest stable version of their favorite library.  This can be a real time saver in searching out the various library links.  It would be really nice if they also had associated elements like the sets of pre-constructed stylesheets for jQuery UI.  I keep a list here: <a href="http://www.stemkoski.com/jquery-ui-1-7-2-themes-list-at-google-code/">http://www.stemkoski.com/jquery-ui-1-7-2-themes-list-at-google-code/</a> but being able to get all of that information in one location would be fantastic.</p>
<p>Right now SrcriptSrc.net supports jQuery, jQuery UI, Chrome Frame, SwfObject, MooTools,m Prototype, YUI, Dojo, ExtJS, and Script.aculo.us.  All you have to do is find your library, click on the copy button, and you have on your clipboard all of the code required to embed the library.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.stemkoski.com/easily-find-the-latest-versions-of-javascript-libraries-at-google-code/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Google Analytics Not Tracking Data on Your Website? Could be a JavaScript Error.</title>
		<link>http://www.stemkoski.com/google-analytics-not-tracking-data-on-your-website-could-be-a-javascript-error/</link>
		<comments>http://www.stemkoski.com/google-analytics-not-tracking-data-on-your-website-could-be-a-javascript-error/#comments</comments>
		<pubDate>Wed, 10 Feb 2010 19:01:53 +0000</pubDate>
		<dc:creator>Ryan Stemkoski</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Google Analytics]]></category>
		<category><![CDATA[Web Design]]></category>

		<guid isPermaLink="false">http://www.stemkoski.com/?p=1386</guid>
		<description><![CDATA[This fix wont solve all Google Analytics tracking problems but it does address a specific issue. Outside of this problem, there are many other issues including disabled cookies, disabled JavaScript etc. that cannot be helped or fixed. If you have an existing website and Google Analytics is installed properly but is not collecting data please [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.stemkoski.com/wp-content/uploads/2010/02/1246831917417792463.png"><img src="http://www.stemkoski.com/wp-content/uploads/2010/02/1246831917417792463.png" alt="" title="1246831917417792463" width="256" height="256" style="float:right;" /></a>This fix wont solve all Google Analytics tracking problems but it does address a specific issue.  Outside of this problem, there are many other issues including disabled cookies, disabled JavaScript etc. that cannot be helped or fixed. If you have an existing website and Google Analytics is installed properly but is not collecting data please read on.</p>
<p>I recently talked to a new customer with an existing website.  Her website was working great and was bringing in lots of business, however, no matter what she did she could not get Google Analytics to work on her website.  The website was well designed, and modern, the Google Analytics tracking code was installed properly and the code did not contain any errors.  I was perplexed so I started digging deeper.</p>
<h3>The Solution:</h3>
<p>After reviewing her code and analyzing her website I started reviewing the source code to see if some of the other JavaScript was somehow interfering with the Google Analytics.  This was not the problem, but the problem was directly related to JavaScript.  Some of the JavaScript code copy and pasted from another source contained a small syntax error.  This syntax error occurred early in the page and was preventing the rest of the on page JavaScript including Google Analytics from being executed.  The error, didn’t however effect the user experience and had gone unnoticed by her previous development company.  Once we repaired the issue Google Analytics begin to function as expected.</p>
<p>Note:  If you think this may be your problem I would suggest installing the web developer toolbar for Firefox.  It has a fantastic error and warning notification system that will help you find and debug these types of errors.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.stemkoski.com/google-analytics-not-tracking-data-on-your-website-could-be-a-javascript-error/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Software to Automatically Make a HTML version of a Dynamic Website</title>
		<link>http://www.stemkoski.com/software-to-automatically-make-a-html-version-of-a-dynamic-website/</link>
		<comments>http://www.stemkoski.com/software-to-automatically-make-a-html-version-of-a-dynamic-website/#comments</comments>
		<pubDate>Fri, 04 Dec 2009 14:00:07 +0000</pubDate>
		<dc:creator>Ryan Stemkoski</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[PHP Development]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Zipline]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Website Backup]]></category>

		<guid isPermaLink="false">http://www.stemkoski.com/?p=1351</guid>
		<description><![CDATA[It seems like there are a million different content management systems out there. Some like the ZLCMS system we use at Zipline are transferrable to another web host but occasionally we have run into web development companies with ‘proprietary’ content management systems. Many of these companies won’t allow their customers to transfer their website to [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>It seems like there are a million different content management systems out there.  Some like the ZLCMS system we use at Zipline are transferrable to another web host but occasionally we have run into web development companies with ‘proprietary’ content management systems. Many of these companies won’t allow their customers to transfer their website to another hosting company. Often, when we run into these situations the customers are willing to forfeit their content management just to get away from the web development company they are working with.  On a few of these occasions we have been forced to hand backup an entire HTML website, updating images, links, etc.</p>
<p>Years ago I had a software program that would copy down an entire HTML site fairly accurately.  Unfortunately, as the web transitioned to dynamic websites this software package could not keep up with the advances.</p>
<p>Today, I discovered a website backup utility that has done a fantastic job in my tests.   I backed up several of our complicated dynamic websites and it has done a great job making them work in an HTML version.  If you run into a situation where your website, or your customers website is being held hostage by a web design company this could be the perfect solution for you.</p>
<p>The software is called HTTrack Website Copier and it is a free GPL licensed software package.</p>
<h3><a href="http://download.httrack.com/cserv.php3?File=httrack.exe">Click here to download HTTrack</a></h3>
<p></p>
<p>If you have any comments or questions please leave a comment below. </p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.stemkoski.com/software-to-automatically-make-a-html-version-of-a-dynamic-website/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to Detect IE6 Browser with JavaScript</title>
		<link>http://www.stemkoski.com/how-to-detect-ie6-with-javascript/</link>
		<comments>http://www.stemkoski.com/how-to-detect-ie6-with-javascript/#comments</comments>
		<pubDate>Mon, 19 Oct 2009 15:20:56 +0000</pubDate>
		<dc:creator>Ryan Stemkoski</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[PHP Development]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Browser Detection]]></category>
		<category><![CDATA[IE6]]></category>
		<category><![CDATA[Internet Explorer 6]]></category>

		<guid isPermaLink="false">http://www.stemkoski.com/?p=1306</guid>
		<description><![CDATA[I have been doing a lot of work with jQuery lately. The jQuery library offers great cross browser support for most functions but unfortunately even this magic wand can’t solve all the problems with Internet Explorer 6 (IE6) compatibility. Previously, jQuery had a browser() function that helped detect a browser so that a developer could [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>I have been doing a lot of work with jQuery lately. The jQuery library offers great cross browser support for most functions but unfortunately even this magic wand can’t solve all the problems with Internet Explorer 6 (IE6) compatibility. Previously, jQuery had a browser() function that helped detect a browser so that a developer could build  a work around. The browser() function has been removed in favor of a new function called support() which helps determine if the current browser offers support for a specific piece of functionality.  For many tasks this strategy works just fine but I have found some occasions where I need to sniff out IE6 and it can be done easily using standard JavaScript.</p>
<h3>JavaScript function to determine if the current browser is IE6:</h3>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">//CHECK FOR IE6</span>
<span style="color: #003366; font-weight: bold;">function</span> is_ie6<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
     <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">XMLHttpRequest</span> <span style="color: #339933;">==</span> undefined<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span>ActiveXObject <span style="color: #339933;">!=</span> undefined<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>There are many other ways to find IE6 but this one works great.  If you have another good method please list it in the comments below.  </p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.stemkoski.com/how-to-detect-ie6-with-javascript/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>A Little Known List of JavaScript Functions Equivalent to PHP Functions in jQuery</title>
		<link>http://www.stemkoski.com/a-little-known-list-of-javascript-functions-equivalent-to-php-functions-in-jquery/</link>
		<comments>http://www.stemkoski.com/a-little-known-list-of-javascript-functions-equivalent-to-php-functions-in-jquery/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 14:18:30 +0000</pubDate>
		<dc:creator>Ryan Stemkoski</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[PHP Development]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[.jQuery.map()]]></category>
		<category><![CDATA[array_map()]]></category>
		<category><![CDATA[array_merge()]]></category>
		<category><![CDATA[array_unique()]]></category>
		<category><![CDATA[get_object_vars()]]></category>
		<category><![CDATA[in_array()]]></category>
		<category><![CDATA[is_array()]]></category>
		<category><![CDATA[jQuery.each()]]></category>
		<category><![CDATA[jQuery.extend()]]></category>
		<category><![CDATA[jQuery.grep()]]></category>
		<category><![CDATA[jQuery.inArray()]]></category>
		<category><![CDATA[jQuery.isArray()]]></category>
		<category><![CDATA[jQuery.makeArray()]]></category>
		<category><![CDATA[jQuery.merge()]]></category>
		<category><![CDATA[jQuery.unique()]]></category>

		<guid isPermaLink="false">http://www.stemkoski.com/?p=1212</guid>
		<description><![CDATA[Many of us PHP developers often find working with JavaScript arrays to be a frustrating task. PHP has a number of very powerful built in functions like: in_array(), is_array(), array_merge(), array_map(), and array_unique() that are just plain missing in JavaScript. Over the years, many of these functions have been ported into JavaScript buy developers much [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>Many of us PHP developers often find working with JavaScript arrays to be a frustrating task. PHP has a number of very powerful built in functions like: <strong>in_array(), is_array(), array_merge(), array_map(), and array_unique()</strong> that are just plain missing in JavaScript.  Over the years, many of these functions have been ported into JavaScript buy developers much like us. In fact, I recently did a port partial port of the PHP strip_tags() function to JavaScript.  (Note: There is a popular library of PHP->JS functions called PHP.JS you can check out for functions not included in this example or if you are not using jQuery.)</p>
<p>Until now, developers working with arrays in JavaScript were either forced to obtain the data returned from these functions on their own or spend a great deal of time searching the net for a solution that actually works.  Thankfully, the jQuery developers have written a number of these functions into the core jQuery library but for some reason not many developers, even those using jQuery don’t know they are there to use!</p>
<h3>jQuery / JavaScript PHP Equivalent Array Functions</h3>
<p></p>
<p><strong>PHP in_array() Equivalent in JavaScript</strong></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">jQuery.<span style="color: #660066;">inArray</span><span style="color: #009900;">&#40;</span>value<span style="color: #339933;">,</span>array<span style="color: #009900;">&#41;</span></pre></div></div>

<p><strong>PHP is_array() Equivalent in JavaScript</strong></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">jQuery.<span style="color: #660066;">isArray</span><span style="color: #009900;">&#40;</span>array<span style="color: #009900;">&#41;</span></pre></div></div>

<p><strong>PHP array_map() Equivalent in JavaScript</strong></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">jQuery.<span style="color: #660066;">map</span><span style="color: #009900;">&#40;</span>array<span style="color: #339933;">,</span>callback<span style="color: #009900;">&#41;</span></pre></div></div>

<p><strong><br />
PHP array_merge() Equivalent in JavaScript</strong></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">jQuery.<span style="color: #660066;">merge</span><span style="color: #009900;">&#40;</span>array1<span style="color: #339933;">,</span>array2<span style="color: #009900;">&#41;</span></pre></div></div>

<p><strong>PHP array_unique () Equivalent in JavaScript</strong></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">jQuery.<span style="color: #660066;">unique</span><span style="color: #009900;">&#40;</span>array<span style="color: #009900;">&#41;</span></pre></div></div>

<p></p>
<h3>Other jQuery / JavaScript Array and Object Functions</h3>
<p>
In addition to these functions there are some other handy functions available to jQuery developers that work with Arrays and Objects. These include:</p>
<p><strong>PHP get_object_vars() Equivalent in JavaScript</strong></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">jQuery.<span style="color: #660066;">makeArray</span><span style="color: #009900;">&#40;</span>object<span style="color: #009900;">&#41;</span></pre></div></div>

<p><strong>Grep Style Search Function</strong></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">jQuery.<span style="color: #660066;">grep</span><span style="color: #009900;">&#40;</span>array<span style="color: #339933;">,</span>callback<span style="color: #339933;">,</span>invert<span style="color: #009900;">&#41;</span></pre></div></div>

<p><strong>Object Extension</strong></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">jQuery.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span>deep<span style="color: #339933;">,</span>target<span style="color: #339933;">,</span>object1<span style="color: #339933;">,</span>objectN<span style="color: #009900;">&#41;</span></pre></div></div>

<p><strong>Iterator Function</strong></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">jQuery.<span style="color: #660066;">each</span> <span style="color: #009900;">&#40;</span>object<span style="color: #339933;">,</span>callback<span style="color: #009900;">&#41;</span></pre></div></div>

<p><em>(Note: None of these functions will work without the jQuery library. jQuery is a free, open source JavaScript library check out: <a href="http://jquery.com/">http://jquery.com/</a> for more information.)</em></p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.stemkoski.com/a-little-known-list-of-javascript-functions-equivalent-to-php-functions-in-jquery/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Problem with jQuery UI Datepicker and Copied Dynamic DOM: Solved</title>
		<link>http://www.stemkoski.com/problem-with-jquery-ui-datepicker-dynamic-dom/</link>
		<comments>http://www.stemkoski.com/problem-with-jquery-ui-datepicker-dynamic-dom/#comments</comments>
		<pubDate>Mon, 14 Sep 2009 19:10:50 +0000</pubDate>
		<dc:creator>Ryan Stemkoski</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Date Picker]]></category>
		<category><![CDATA[datepicker]]></category>
		<category><![CDATA[jQuery UI]]></category>

		<guid isPermaLink="false">http://www.stemkoski.com/?p=1190</guid>
		<description><![CDATA[Today, I ran into an interesting problem with the jQuery UI Datepicker, for which I couldn’t find any assistance. In retrospect, it was a fairly simple issue but it took me quite awhile to debug. If I didn’t have Firebug, I don’t think it would’ve ever been solved this issue. I spent a great deal [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>Today, I ran into an interesting problem with the jQuery UI Datepicker, for which I couldn’t find any assistance. In retrospect, it was a fairly simple issue but it took me quite awhile to debug. If I didn’t have Firebug, I don’t think it would’ve ever been solved this issue. I spent a great deal of time searching for solutions on Google but unfortunately nobody was able to help me solve my problem so I thought I would document this here for anyone else in the same shoes.<br />
<strong><br />
What I was up to:</strong><br />
I was trying to create a dynamic address section.  I was using some simple jQuery to copy a section of code (.address_template) and then I was using jQuery to inject it into the document. The goal was to allow the user to add an unlimited number of previous addresses, each with a start and end date selectable using the jQuery UI datepicker.</p>
<p><strong>The problem:</strong><br />
In my document, I was using jQuery to create instances of datepicker() for each  instance of .address_date.  This worked great for the single instance that appeared but failed miserably for elements added dynamically to the DOM after the page had loaded. I tried various solutions I found for similar problems other users had. Some of these included:</p>
<p>- Adding a unique ID to each instance of the datepicker.<br />
- Using datepicker(“destroy”) then redeclaring datepicker()</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">#<span style="color: #009900;">&#40;</span>‘address_template’<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">datepicker</span><span style="color: #009900;">&#40;</span>‘destroy’<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">datepicker</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This technique works excellent if all of your elements were added properly to DOM but I discovered another but I wasn’t expecting.</p>
<p><strong>What I was doing wrong:</strong><br />
I was copying the HTML after the datepicker(); had been initially added to the template.  This means I was copying the HTML after the datepicker() function had modified it.  Before I spent some time analyzing the HTML with Firebug I didn’t realize that the datepicker() function actually modifies the HTML adding in its own class .hasDatepicker.</p>
<p>When I copied the HTML I was copying the HTML after this class was added so the jQuery UI failed when trying to initiate a new datepicker(); and datepicker(“destroy”); failed because a true instance didn’t exist. I was caught in a real catch 22. </p>
<p>How I solved the problem:<br />
I modified my code to reset the style of the .address_date class when I added it into the DOM prior to adding datepicker to that specific element. As soon as I did this it began to work sweet.</p>
<p>Below is an example of my code in case it is helpful to anyway. This one is really more about theory than exact code:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#addaddress'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> count <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.address_template'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> html <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.address_template'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">eq</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#addaddress'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">before</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;div class=&quot;address_template&quot;&gt;'</span> <span style="color: #339933;">+</span> html <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;/div&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.address_template H1'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">eq</span><span style="color: #009900;">&#40;</span>count<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Previous Address &quot;</span> <span style="color: #339933;">+</span> count<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.address_date'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">eq</span><span style="color: #009900;">&#40;</span>count<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;class&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;address_date&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.address_date'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">eq</span><span style="color: #009900;">&#40;</span>count<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;id&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;movein&quot;</span> <span style="color: #339933;">+</span> count<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#movein&quot;</span> <span style="color: #339933;">+</span> count<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">datepicker</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Also here are the reference posts from  stackoverflow that helped me reach my solution:<br />
1. <a href="http://stackoverflow.com/questions/34790/duplicating-jquery-datepicker/1423156#1423156">http://stackoverflow.com/questions/34790/duplicating-jquery-datepicker/1423156#1423156</a></p>
<p>2. <a href="http://stackoverflow.com/questions/1059107/why-does-jquery-uis-datepicker-break-with-a-dynamic-dom">http://stackoverflow.com/questions/1059107/why-does-jquery-uis-datepicker-break-with-a-dynamic-dom</a></p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.stemkoski.com/problem-with-jquery-ui-datepicker-dynamic-dom/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>What is JavaScript’s Equivalent to PHP strip_tags()</title>
		<link>http://www.stemkoski.com/what-is-javascript%e2%80%99s-equivalent-to-php-strip_tags/</link>
		<comments>http://www.stemkoski.com/what-is-javascript%e2%80%99s-equivalent-to-php-strip_tags/#comments</comments>
		<pubDate>Mon, 24 Aug 2009 15:15:39 +0000</pubDate>
		<dc:creator>Ryan Stemkoski</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PHP Development]]></category>
		<category><![CDATA[Zipline]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[strip_tags()]]></category>

		<guid isPermaLink="false">http://www.stemkoski.com/?p=1175</guid>
		<description><![CDATA[A couple of days ago I was working on a project using jQuery where I was traversing through a table and totaling several numeric values. The problem I ran into was that most of these values were wrapped in HTML tags and the tags were not standardized from field to field so a simple replace() [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>A couple of days ago I was working on a project using jQuery where I was traversing through a table and totaling several numeric values.  The problem I ran into was that most of these values were wrapped in HTML tags and the tags were not standardized from field to field so a simple replace() was not sufficient.</p>
<p>Unfortunately, much to my dismay jQuery does not have a built in function to strip HTML from a string like the handy strip_tags() PHP offers.  I did some searching online and was able to track down a couple functions written by other developers that were able to do this task.  I have taken my two favorites and combined them into the solution provided below.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">	<span style="color: #006600; font-style: italic;">/***************************************************
	STRIP HTML TAGS
	****************************************************/</span>
	<span style="color: #003366; font-weight: bold;">function</span> strip_tags<span style="color: #009900;">&#40;</span>html<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">//PROCESS STRING</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>arguments.<span style="color: #660066;">length</span> <span style="color: #339933;">&lt;</span> <span style="color: #CC0000;">3</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			html<span style="color: #339933;">=</span>html.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/&lt;\/?(?!\!)[^&gt;]*&gt;/gi</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003366; font-weight: bold;">var</span> allowed <span style="color: #339933;">=</span> arguments<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
			<span style="color: #003366; font-weight: bold;">var</span> specified <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">eval</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;[&quot;</span><span style="color: #339933;">+</span>arguments<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;]&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>allowed<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				<span style="color: #003366; font-weight: bold;">var</span> regex<span style="color: #339933;">=</span><span style="color: #3366CC;">'&lt;/?(?!('</span> <span style="color: #339933;">+</span> specified.<span style="color: #660066;">join</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'|'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'))<span style="color: #000099; font-weight: bold;">\b</span>[^&gt;]*&gt;'</span><span style="color: #339933;">;</span>
				html<span style="color: #339933;">=</span>html.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">new</span> RegExp<span style="color: #009900;">&#40;</span>regex<span style="color: #339933;">,</span> <span style="color: #3366CC;">'gi'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>
				<span style="color: #003366; font-weight: bold;">var</span> regex<span style="color: #339933;">=</span><span style="color: #3366CC;">'&lt;/?('</span> <span style="color: #339933;">+</span> specified.<span style="color: #660066;">join</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'|'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">')<span style="color: #000099; font-weight: bold;">\b</span>[^&gt;]*&gt;'</span><span style="color: #339933;">;</span>
				html<span style="color: #339933;">=</span>html.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">new</span> RegExp<span style="color: #009900;">&#40;</span>regex<span style="color: #339933;">,</span> <span style="color: #3366CC;">'gi'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">//CHANGE NAME TO CLEAN JUST BECAUSE </span>
		<span style="color: #003366; font-weight: bold;">var</span> clean_string <span style="color: #339933;">=</span> html<span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">//RETURN THE CLEAN STRING</span>
		<span style="color: #000066; font-weight: bold;">return</span> clean_string<span style="color: #339933;">;</span></pre></div></div>

<p>If you are using this function you probably know your way around JavaScript well enough you don&#8217;t need a complete example but if you do here is a quick and dirty one:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot; /&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
&nbsp;
	/***************************************************
	STRIP HTML TAGS
	****************************************************/
	function strip_tags(html){
&nbsp;
		//PROCESS STRING
		if(arguments.length &lt; 3) {
			html=html.replace(/&lt;\/?(?!\!)[^&gt;]*&gt;/gi, '');
		} else {
			var allowed = arguments[1];
			var specified = eval(&quot;[&quot;+arguments[2]+&quot;]&quot;);
			if(allowed){
				var regex='&lt;/?(?!(' + specified.join('|') + '))\b[^&gt;]*&gt;';
				html=html.replace(new RegExp(regex, 'gi'), '');
			} else{
				var regex='&lt;/?(' + specified.join('|') + ')\b[^&gt;]*&gt;';
				html=html.replace(new RegExp(regex, 'gi'), '');
			}
		}
&nbsp;
		//CHANGE NAME TO CLEAN JUST BECAUSE 
		var clean_string = html;
&nbsp;
		//RETURN THE CLEAN STRING
		return clean_string;
	}
&nbsp;
&lt;/script&gt;
&lt;/head&gt;
&lt;script type=&quot;text/javascript&quot;&gt; 
	var sample_html = '&lt;h1&gt;&lt;a href=&quot;http://www.gozipline.com&quot;&gt;Zipline Interactive&lt;/a&gt;&lt;/h1&gt;';
	document.write('Without Stripping Tags : ' + sample_html);
	var demo = strip_tags(sample_html);
	document.write('With Stripping Tags: ' + demo);
&lt;/script&gt;
&lt;body&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></div></div>



<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.stemkoski.com/what-is-javascript%e2%80%99s-equivalent-to-php-strip_tags/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Stupid Simple jQuery Accordion Menu</title>
		<link>http://www.stemkoski.com/stupid-simple-jquery-accordion-menu/</link>
		<comments>http://www.stemkoski.com/stupid-simple-jquery-accordion-menu/#comments</comments>
		<pubDate>Sun, 08 Mar 2009 14:02:25 +0000</pubDate>
		<dc:creator>Ryan Stemkoski</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Zipline]]></category>
		<category><![CDATA[Accordion]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.stemkoski.com/?p=1079</guid>
		<description><![CDATA[This is a very simple tutorial on how to implement an accordion style menu using jQuery to manipulate a grouping of DIV elements.  This system is so simple it could be easily utilized by someone who has little or no jQuery experience.  

This example provides a complete overview of the implementation as well as a demo and code download to help you get the system running on your web based application.


No related posts.]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.stemkoski.com/wp-content/uploads/2009/03/roland22fr5accordion.jpg" alt="roland22fr5accordion" title="roland22fr5accordion" width="250" height="228" style="float:right;" />Last week I had to create an accordion style menu for a project.  Accordion menus are a very, very handy tool to show and hide information as needed.  I have used them on sites like http://www.spokanesymphony.org and http://2008-2009.spokanesymphony.org. While the accordion system I used on these sites worked well, I decided to write my own using jQuery with the goal of making it as simple as possible. </p>
<p>I have found many of the existing accordion menu systems to be bloated and difficult to understand.  I knew there had to be an easier way to create an accordion menu.  Instead of using a list like most alternate systems, this system uses a grouping of DIV elements with specific names.  </p>
<h3>ORIGINAL VERSION: <a href="http://www.stemkoski.com/downloads/jquery-accordion-menu/example.htm" target="_blank">DEMO</a> | <a href="http://www.stemkoski.com/downloads/jquery-accordion-menu.zip">DOWNLOAD</a></h3>
<h3>UPDATED VERSION: <a href="http://www.stemkoski.com/downloads/jquery-accordion-menu-update/example.htm" target="_blank">DEMO</a> | <a href="http://www.stemkoski.com/downloads/jquery-accordion-menu-update.zip">DOWNLOAD</a> *</h3>
<p><em><strong>* Note: The updated version was released on 3/25/10 and it is slightly different than the example detailed in this post, however, installation is virtually the same. The updated version addresses a number of frequent feature requests from fans of the script. These include use of  jQuery 1.4.2, adding a mouseover effect, adding a selected effect, and the ability to close open menus by clicking their header.</strong></em></p>
<p>Note: Here is an <a href="http://www.stemkoski.com/downloads/jquery-accordion-menu-open.zip">example of how to pin open the first item</a> and an <a href="http://www.stemkoski.com/downloads/jquery-accordion-menu-pin-open.zip">example of how to select any item to pin open on load</a>.
</p>
<p>
<div style="border-bottom: 1px solid #000000;">&nbsp;</div>
</p>
<p>&nbsp; </p>
<h3 style="padding-bottom: 8px;">How to implement this jQuery accordion style menu:</h3>
<h4>Step 1 &#8211; Include jQuery:</h4>
<p>For a jQuery beginner the first thing you need to do is to include the jQuery library.  Google hosts the library so you can link to it there.  This can be done by putting the following code in the head of your document:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span> src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js&quot;</span><span style="color: #339933;">&gt;</span> <span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<h4>Step 2: &#8211; Create the JavaScript</h4>
<p>Next you need to create a blank JavaScript file.  For the example, this file is called javascript.js.  This file will contain the jQuery code required for the menu.  Once you save the file include it in the head of your document with the proper path just as we did the jQuery library in Step 1. An example of the JavaScript code to include in this document is shown below:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #006600; font-style: italic;">//ACCORDION BUTTON ACTION	</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.accordionButton'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.accordionContent'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideUp</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'normal'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">next</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideDown</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'normal'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #006600; font-style: italic;">//HIDE THE DIVS ON PAGE LOAD	</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;div.accordionContent&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h4>Step 3 &#8211; Create the CSS: </h4>
<p>Now we need to create a CSS document with our two selectors accordionButton and accordionContent and then include that in the head of the document.  Examples of these selectors are included below.  The color, contents, and visual formatting can all be manipulated.  It is important these elements retain their float: left or display: inline-block property so that they will display inline.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#wrapper</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">800px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.accordionButton</span> <span style="color: #00AA00;">&#123;</span>	
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">800px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#003366</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border-bottom</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#FFFFFF</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">cursor</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">pointer</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.accordionContent</span> <span style="color: #00AA00;">&#123;</span>	
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">800px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#95B1CE</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span></pre></div></div>

<h4>Step 4 &#8211; Create the HTML:</h4>
<p>Now we need to create the HTML we’re going to manipulate.  For this example we will keep the page very, very simple. In a more complicated HTML document you need to make sure the two classes used for the accordion DIV items are not used elsewhere.  jQuery will be looking for the class of the element so if it is present elsewhere in the HTML document it will cause some unexpected problems. The full HTML document also displaying the includes is shown below:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #00bbdd;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span> xmlns<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.w3.org/1999/xhtml&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">meta</span> <span style="color: #000066;">http-equiv</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Content-Type&quot;</span> <span style="color: #000066;">content</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/html; charset=iso-8859-1&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">title</span>&gt;</span>jQuery Accordion Style DIV Menu<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">title</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">link</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;style/format.css&quot;</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">link</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;style/text.css&quot;</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js&quot;</span>&gt;</span> <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;includes/javascript.js&quot;</span>&gt;</span> <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;wrapper&quot;</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;accordionButton&quot;</span>&gt;</span>Button 1 Content<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;accordionContent&quot;</span>&gt;</span>Content 1<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span>Long Example<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;accordionButton&quot;</span>&gt;</span>Button 2 Content<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;accordionContent&quot;</span>&gt;</span>Content 2<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span>Medium Example<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;accordionButton&quot;</span>&gt;</span>Button 3 Content<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;accordionContent&quot;</span>&gt;</span>Content 1<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span>Short Example<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;accordionButton&quot;</span>&gt;</span>Button 4 Content<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;accordionContent&quot;</span>&gt;</span>Content 4<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span>Extra Long Example<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></pre></div></div>

<p>Notice that we have alternating rows with the styles accrodionButton and accordionContent.  Clicking accordionButton will trigger the drop of the next instance of accordionContent. It is very important these elements alternate properly with nothing inbetween for the system to function properly.  Each element can contain HTML, nested divs, or other styling elements.</p>
<h4>Step 5 &#8211; Check out the Result!: </h4>
<p>Now we have all of our code we need.  View the system in the browser and it should work great.  Clicking on each button will cause the content below it to drop.  The content will retract if another button is clicked. (Note: If you needed to keep the content elements open after a click on a seperate button instead of having them retract you can do this easily by removing this line from the javascript.js include:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.accordionContent'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideUp</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'normal'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h4>View a complete example or download a complete example:</h4>
<p><a href="http://www.stemkoski.com/downloads/jquery-accordion-menu/example.htm" target="_blank">Click here to view the demo of the accordion style jQuery menu</a></p>
<p><a href="http://www.stemkoski.com/downloads/jquery-accordion-menu.zip" target="_blank">Click here to download the demo files for the jQuery accordion style menu</a></p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.stemkoski.com/stupid-simple-jquery-accordion-menu/feed/</wfw:commentRss>
		<slash:comments>431</slash:comments>
		</item>
	</channel>
</rss>

