Evening folks,
Have just discovered jQuery and have implemented a sliding menu on my new personal site that's currently in development.
The menu works brilliantly, no issues at all, but I'm wondering how I'd go about making one slight modification.
Code:
// jQuery Menu
$(document).ready(function(){
// Set default menu states
expanded = $('li.expanded > h1');
expanded.css('cursor', 'pointer');
jQuery.each(expanded, function(){
$(this).text('- ' + $(this).text());
});
collapsed = $('li.collapsed > h1');
collapsed.css('cursor', 'pointer').next('ul').css('display', 'none');
jQuery.each(collapsed, function(){
$(this).text('+ ' + $(this).text());
});
// Switch menu states when the menu headers are clicked
$('li.toggleable > h1').click(function(){
menu_header = $(this);
menu_header.next('ul').slideToggle('normal');
if (menu_header.text().substring(0, 2) == '+ ')
menu_header.text('- ' + menu_header.text().substring(2));
else if (menu_header.text().substring(0, 2) == '- ')
menu_header.text('+ ' + menu_header.text().substring(2));
});
});
What I want to modify is the
+ it adds to collapsed parts of the menu and the
- it adds to the expanded parts of the menu. Instead of the + and - I'd like to have an image instead.
Any advice how I go about changing the code to do this?
As always, thanks in advance :-)