How to jump to the page with jquery

藏色散人
Release: 2022-12-30 11:13:04
Original
21722 people have browsed it

The jquery method to jump to a page: first introduce the jquery file into the page; then create a button to trigger the jump; then add a click event for the jump button; finally operate the location object through jquery, and Call the attr method and assign the href attribute to the new url address.

Operating environment:Acer S40-51, Windows10 Home Chinese version, jquery1.8.3&&HBuilderX.3.0.5

Recommendation: "jquery video Tutorial

jquery jump page

First, you need to introduce the script library file into the page.

How to jump to the page with jquery

Then create an html sample file test, and create a button to trigger the jump. Note that the current page is called 'Page A'. Then write JS script logic to add a click event for the jump button. We know that in native js, we use the location attribute in the window object to handle jumps. window.location.href = "abc.html"

Manipulate the location object through jquery and call attr Method, just assign the href attribute to the new url address.

test complete code:

    Title  

这是页面A

Copy after login

Run the page and click the ‘Jump’ button above.

How to jump to the page with jquery

(Note that you are now in page A)

After clicking, you will successfully jump to the new page, (testb)

How to jump to the page with jquery

testb code such as:

    Title 

这是页面B

Copy after login

For more computer programming related knowledge, please visit:Programming Teaching! !

The above is the detailed content of How to jump to the page 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
Popular Recommendations
Popular Tutorials
More>
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!