整个页面中英文切换代码
时间: 2023-09-19 22:08:43 浏览: 51
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Language Switcher</title>
</head>
<body>
<header>
<nav>
<ul>
<li><a href="#" onclick="switchLang('en')">English</a></li>
<li><a href="#" onclick="switchLang('zh')">中文</a></li>
</ul>
</nav>
</header>
<main>
<section id="en">
<h1>Welcome to our website</h1>
<p>Here you can find all the information you need about our products and services.</p>
</section>
<section id="zh" style="display:none;">
<h1>欢迎来到我们的网站</h1>
<p>在这里,您可以找到有关我们的产品和服务的所有信息。</p>
</section>
</main>
<footer>
<p>© 2021 Language Switcher</p>
</footer>
<script>
function switchLang(lang) {
if (lang === 'en') {
document.getElementById('en').style.display = 'block';
document.getElementById('zh').style.display = 'none';
} else if (lang === 'zh') {
document.getElementById('en').style.display = 'none';
document.getElementById('zh').style.display = 'block';
}
}
</script>
</body>
</html>
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)