[jQuery] Problem trying to select a ul with only one li in JQuery

[jQuery] Problem trying to select a ul with only one li in JQuery


Given a ul hierarchy as below, I'm struggling to write a JQuery
selector that will give me a ul that contains only one li element,
that I can then add a class to, in this example the ul is the one that
contains the li "Only Child".
<ul>
<li><div><a href="#">First</a></div>
<ul>
<li><div><a href="#">Only Child</a></div></li>
</ul>
</li>
<li><div><a href="#">Second</a></div></li>
</ul>
So far I've tried permuations on a theme of:
$("ul:has(li:only-child)").addClass("solo");
and
$("ul li:only-child").addClass("solo"); - this one gets close, but
adds the class to the li rather than the ul.
I'm sure this is possible, so any help gratefully received,
Chris