Javascript methods working