Adding example using jquery when and then