+2  A: 

You can remove the complex logic from clearSearch and just have it clear the search box. Then add some new onClick handlers to the elements you don't want to call this method. In those handlers set event.cancelBubble to true to prevent the clearSearch function being called.

From quirksmode:

For a complete cross-browser experience do:

function doSomething(e)
{
    if (!e) var e = window.event;
    e.cancelBubble = true;
    if (e.stopPropagation) e.stopPropagation();
}
Mark Byers
Right, but do I have to do it on each element or does cancel bubble on the ul take care of all it's child elements?
sobertillnoon
@sobertilnoon: If you stop event bubbling on the <ul>, it will also work for all its list items.
Mark Byers
@Mark: yeah, I just have to make sure that the event is in bubble mode not capture mode. worked once I realized I put true not false. thanks.
sobertillnoon