Instead of inspecting the title text, I'd suggest just testing button.hasClass("active"), as that seems likely to be more resiliient to possible UX changes.