Firstly I would like to apologise if this is off topic. I am unsure if it is, as the code written works fine.
Just wondering how I might convert this to JavaScript from JQuery? The code below expands a menu on click like an accordion but I am trying to rewrite this in JS for practise.
( function( $ ) {
$( document ).ready(function() {
$('#accordianMenu > ul > li > a').click(function() {
$('#accordianMenu li').removeClass('active');
$(this).closest('li').addClass('active');
var checkElement = $(this).next();
if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
$(this).closest('li').removeClass('active');
checkElement.slideUp('normal');
}
if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
$('#accordianMenu ul ul:visible').slideUp('normal');
checkElement.slideDown('normal');
}
if($(this).closest('li').find('ul').children().length == 0) {
return true;
} else {
return false;
}
});
});
} )( jQuery );