We have validated your query.
Based on your code snippet. we have prepared the sample and its working fine in our end. We suspect that you did not refer the jquery file in Layout.cshtml.
If so please refer the below cdn in head section
If we misunderstood your requirement please get back us with further details like,
1. Issue reproducing video.
2. Issue reproducing sample.