Search code examples
jqueryasp.net.netrazorasp.net-mvc-5

How to put @ symbol in jquery code in mvc5 razor view


I have longitude and lattitude positions and now I want to show the longitude and lattitude in google maps ... This is a link through which we can show it for free ... https://www.google.com/maps/@30,70z ...

$('btn-location').click(function () {
        var lon = $('longitude').text(); // value here is 70
        var lat = $('latitude').text(); // value here is 30

        window.location.replace("https://www.google.com/maps/@" + lat + "," + lon + "z");
    });

Here is the code using jquery but I am getting error on @ symbol ....


Solution

  • As @ is special character in Razor pages you need to escape it. Just use @@.