Extract URL from a list item newbie question

Extract URL from a list item newbie question

I am a total newbie as far as jQuery is concerned so this may be obvious to those with a little more experience but I have inherited some code which provides an autosuggest list as an HTML list .. the items in the list can be highlighted using the up and down arrow keys and if you click on a highlighted item using the mouse a new URL can be triggered.  What I want to be able to do, though, is also allow the user to hit ENTER on the selected item and fire the URL that way.

This seems to be the bit of code that I need to modify:

                             case 13:
                                str = $(".list li[class='selected']").text();
                                obj.val(str);
                                // store id of the selected option
                                if(idHolder != "" && idHolder != null)
                                $("#"+idHolder).val($(".list li[class='selected'] a").attr("id"));
                                $(".list").fadeOut("fast");
                             break;
                            }

The items in the HTML list that are available for selection appear as follows:

<li><a href="http://etc">Name of list item</a></li>

I believe that the existing code changes the css class of the currently highlighted list item to "selected".

Someone had suggested that:  

window.location = $('.selected li').find('a').attr('url');

might work but that merely gives "undefined".

Any help would be greatly appreciated.