$(location).attr("href");
You can use the Location object and jQuery attr()
method to get the URL of the current page.
Let's take a look at an example to understand how it actually works:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery Get Current Page URL</title>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
var pageURL = $(location).attr("href");
alert(pageURL);
});
});
</script>
</head>
<body>
<button type="button">Get URL</button>
</body>
</html>
Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]
Django - How to create CRUD with Example
Django is the high-level Python Web fram...How to make the first letter of a string uppercase in JavaScript
Use the toUpperCase() method In JavaS...Laravel Validation In Bootstrap Model Using Ajax
Today, Laravelcode share with you how to...How to Create Previous Next Simple Pagination in Laravel?
Laravel provided two type pagination....Build Dynamic Data Table in Vue.js 2+ with Vuetify
In this tutorial, we are going to learn...