How to get current url path example in Jquery?

How to get current url path example in Jquery?

In this post we will give you information about How to get current url path example in Jquery?. Hear we will give you detail about How to get current url path example in Jquery?And how to use it also give you demo for it if it is necessary.

Sometimes we need to get current URL in jquery file, we can get current URL or path of our current page in javascript using “window.location”.

In this post i give you three way to get current url in your js file as there are bellow listed:

1.window.location.href

2.$(location).attr(“href”)

3.window.location

Ok, so you can check bellow example code and run in your system.

Example:

Also see:Laravel – How to get current URL in controller or view?

<html lang="en">


<head>

<title>JQuery - get current URL Example</title>

<script src="https://code.jquery.com/jquery-2.2.2.min.js"></script>

</head>


<body>


<script type="text/javascript">


var currentURL = window.location.href;

alert(currentURL);


var currentURL = $(location).attr("href");

alert(currentURL);


var currentURL = window.location;

alert(currentURL);


</script>


</body>

</html>

Hope this code and post will helped you for implement How to get current url path example in Jquery?. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

Your email address will not be published. Required fields are marked *

5  +    =  15

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US