Hi - I'm using this script for an accordion on a website. I'd like to know if it's possible to amend the script so that when the title of each accordion block is clicked on the block will closed again? Currently each accordion block only closes when the title of another accordion block is clicked on.

$('.accordion ul').hide();
$('.accordion li:first').find('a.title').addClass('tab-active');
$('.accordion ul:first').hide();
$('.accordion li a.title').click(

function() {
var checkElement = $(this).next();
if ((checkElement.is('ul')) && (checkElement.is(':visible'))) {
return false;
if ((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
$('.accordion ul:visible').slideUp(500);
return false;

I'm new to JS so would really appreciate any help! Many thanks.