> $("#PageTemplateForm h4 a").each(function(){ > > I can see why that wouldn't work, because the "expand" div would would > likely be inserted in the wrong place. How would I distinguish > between h4s followed by links vs h4s not followed by links?
How about the :has() selector? $("#PageTemplateForm h4:has(a)") That would only give you the h4 elements that contain an a element.