I was looking over my FAQ Plugin and noticed some strange and sloppy code. Even though no one has mentioned any issues I figured it was worth the time to clean it up and post an updated version. The updates include:
- Changed the content tag from a span to a div. According to the W3C recommendations this is the correct way to nest div and span elements.
- Added an integer to the automatically created id name. This prevents an accidental duplicate of ID’s in your page.
- Changed the regular expression to anything other than alphanumeric. The new regular expression of ‘ \W ’ matches anything other than A-Za-z0-9. So now you are free to use any character in your header.
- Corrected the syntax to accept the faqHeader variable. I had mistakenly hard coded the value “ h2 “ in the selector, ignoring the dynamic variable that might have been passed.
That’s about all the changes but you can see they are significant. If you have already downloaded a copy I would recommend you download the latest version.
jQuery.FAQ.zip v1.1