My script should expand/collapse UL elements when a corresponding is clicked. It works in FF fine and can be viewed over here.
I am loading jQuery lib first then my own examples.js which contains:
function initExamples() {
$('#examples ul').hide();
$('#examples ul:first').show();
$('#examples li a:first').addClass('exampleon');
$('#examples li a').click(function(event) {
event.preventDefault();
var checkElement = $(this).next();
if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
return false;
}
if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
$('#examples a.exampleon').removeClass('exampleon');
$('#examples ul:visible').slideUp('normal');
$(this).addClass('exampleon');
checkElement.slideDown('normal');
return false;
}
}
);
}
$(document).ready(function() {initExamples();});
My HTML on the other hand appears like so:
<ul id="examples">
<li>
<a href="#">TITLE TEXT 1</a>
<ul>
<li><a href="#">MY CONTENT 1</a></li>
</ul>
</li>
<li>
<a href="#">TITLE TEXT 2</a>
<ul>
<li><a href="#">MY CONTENT 2</a></li>
</ul>
</li>
<li>
<a href="#">TITLE TEXT 3</a>
<ul>
<li><a href="#">MY CONTENT 3</a></li>
</ul>
</li>
</ul>
The click() doesn't seem to trigger in IE/Safari/Chrome, but the initial hide/show does, it also triggers the default behaviour and links to 'mypage.html#' I've tried a preventDefault();, but perhaps I did it wrong.
Any help is uber appreciated!