Capturing clicks on list items I am using jQuery's collapsible lists grouped and named #List01, #List02, #List03, etc. My code captures clicks on list elements and remembers list items' ID for further processing. Each group has identically looking code so I was wondering how I could encapsulate it in one function.

$(document).on('click', '#List01 li', function ()
{
    var anchor = $(this).find('a');
    sessionStorage.KenID = anchor.attr('id');
    changePage();
});
$(document).on('click', '#List02 li', function ()
{
    var anchor = $(this).find('a');
    sessionStorage.KenID = anchor.attr('id');
    changePage();
});
$(document).on('click', '#List03 li', function ()
{
    var anchor = $(this).find('a');
    sessionStorage.KenID = anchor.attr('id');
    changePage();
});
$(document).on('click', '#List01 li, #List02 li, #List03 li', function () {
        var anchor = $(this).find('a');
        sessionStorage.KenID = anchor.attr('id');
        changePage();
});


The , should do the trick.