How to set button button to jump to page in html5

WBOY
Release: 2021-12-30 16:37:12
Original
11108 people have browsed it

Method: 1. Use the "" statement uses the a tag to wrap the button element setting.

How to set button button to jump to page in html5

The operating environment of this tutorial: Windows 10 system, HTML5 version, Dell G3 computer.

html5How to set the button button to jump to the page

1. Use the onclick click event and the window.location.href attribute to add clicks to the button element The event jumps to the page.

The syntax is as follows:

<button onclick="window.location.href=跳转地址">按钮</button>
Copy after login

The example is as follows:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<button onclick="window.location.href=&#39;https://www.baidu.com/&#39;">按钮</button>
</body>
</html>
Copy after login

Output result:

How to set button button to jump to page in html5

2. Utilization The a tag wraps the button element, and you can use the href attribute of the a tag to set the jump address.

The example is as follows:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<a href="https://www.baidu.com/"><button>按钮</button></a>
</body>
</html>
Copy after login

The output result is the same as above.

Recommended tutorial: "html video tutorial"

The above is the detailed content of How to set button button to jump to page in html5. 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 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!