How to get the current page url with jQuery

藏色散人
Release: 2018-12-19 09:50:13
Original
13250 people have browsed it


jQuery gets the current page url, we can do it through the syntax $(location).attr("href").

How to get the current page url with jQuery

Below we will combine a simple code example to introduce to you the implementation method ofjQuery to obtain the current page url.

The code example is as follows:

    jquery获取当前页面url示例   
Copy after login

In the above code, a button button is first defined. When the button is clicked, the click event is triggered. In this event, $(location).attr("href ") method to get the complete url address of the current page.

attr() method can set or return the attribute value of the selected element, here is the set href attribute. Finally, the location information obtained is displayed in the front desk through alert, which is the current page URL address.

Then the result of getting the url is as follows:

How to get the current page url with jQuery

This article is about jQuery’s method of getting the URL of the current page. It is also very simple. I hope it will help Friends in need help!


The above is the detailed content of How to get the current page url with jQuery. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!