var btn = $("button:contains('Expand All')"); 

should be enough, no need for an extra function.