I am creating an asp.net MVC application.
I have a view named "receive" and it placed in Views/Main folder.
I am trying to add js file.
In intellisense, I am getting access to js file functions.
But when I run the application, the js file is not linking.
My view is as follow
@model dSite.Models.MModels
<script type="text/javascript" src="../../Scripts/Jquery-2.1.js"> </script>
<script>
$("#btn").click(function ()
{ alert("aa");
});
</script>
@{
ViewBag.Title = "receive";
}
<h2>
receive</h2>
<input type="text" id="txtname" placeholder="enter name" />
<input type="button" id="btn" value="click here" />
And my Scripts folder is at the root.
How can I link my js file to my view? I have tried the above but it's not working
following is the file structure

Js files structure

src, try replacing../../with~/$("#btn")isundefined(and you really should use a tilde<script src="~/Scripts/jquery-2.1.js"></script>$.is not defined in the browser console if it wasn't. The real problem was that you have the script at the top of the page and not inside document.ready. What happens is as the view is rendered, you have$("#btn").click(function ()but at that point the element withid="btn"does not exist (its further down the page) so your actually attaching a.click()to something that does not exist (it'sundefined)